BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

代码代写|CSSE1001/CSSE7030 Garden Gnome Assignment 2 Semester 2 2022

代码代写|CSSE1001/CSSE7030 Garden Gnome Assignment 2 Semester 2 2022

这是一篇来自澳洲的关于花园玉米粒作业的代码代写

 

1 Introduction

Garden Gnome is a single-player simulator game where a player must take care of house plants for 15 days. The player must keep more than half their plants alive for this duration. Items are be rewarded throughout the days to assist the player, and are applied when needed. See Figure 1 for a sample game.

In Assignment 2, you will create an extensible object-oriented implementation of Garden Gnome which employs a text-based interface.

You are required to implement a collection of classes and methods as specified in Section 5 of this document. Your program’s output must match the expected output exactly; minor differences in output (such as white-space or casing) will cause tests to fail, resulting in zero marks for that test. Any changes to this document will be listed in a changelog at the end of the document.

2 Getting Started

Download a2.zip from Blackboard — this archive contains the necessary files to start this assignment.

Once extracted, the a2.zip archive will provide the following files/directories:

a2.py

The game engine. This is the only file you submit and modify. Do not make changes to any other files.

a2_support.py

Provided classes implementing functionality to render the text interface.

constants.py

Constants you may find helpful when writing your assignment.

houses

A folder containing several text files of playable houses.

example_simulations

A folder containing example output from running the completed assignment.

3 Gameplay

The objective is to have more than half the plants alive at day 15. For example, if the game started with ten plants, six plants are required to be alive at day 15 to win the game.

Gameplay occurs according to the following steps:

  1. Prompt user with “Enter house file: ”. Presume the file exists at the location given relative to where a2.py is saved. For instance, houses/house1.txt.
  1. Display house and prompt user with “Enter a move: ”. The list of valid moves are given below. Assume invalid moves may be entered, but ignore them.
  1. Progress to next day when n is entered.
  2. Break on lose or win, otherwise go to step 2.

3.1 Room and position system

The room and position system used for the simulator is depicted in Figure 4. For example in the “Balcony” room there are always four possible positions to place plants, 0, 1, 2, and 3, from left to right, each room has 4 columns at different elevations. Positions are represented as a single int. Note that this is just an example; you must not assume that you will always have a Balcony room.

4 Class overview and relationships

  • Hollow-arrowheads indicate inheritance (i.e. the “is-a” relationship).
  • Dotted arrows indicates composition (i.e. the “has-a” relationship). An arrow marked with 1 1 −−→ denotes that each instance of the class at the base of the arrow contains exactly one instance of the class at the head of the arrow. An arrow marked with 1 n −−→ denotes that each instance of the class at the base of the arrow may contain many instances of the class at the head of the arrow.

E.g. a Model instance may contain many different Room instances, but only one Inventory instance.

  • Green classes are abstract classes. You should only ever instantiate the blue classes in your program, though you should instantiate the green classes to test them before beginning work on their subclasses.
  • The class surrounded by a pink box is provided to you in a2_support.py.

Note that all view classes have been provided to you. You are only required to implement a number of modelling classes and a single controller class which unites these modelling classes with the existing View view class.

5 Implementation

5.1 Model classes

This section outlines the model classes you must implement, along with their required methods. The classes are laid out in the order in which it is recommended you attempt them (with some exceptions that are discussed in the relevant sections).

It is strongly recommended that you ensure a class is working via testing the implementation yourself before moving on to another class (particularly if that class is a superclass of the next class you will attempt).

Entity                               (abstract class)

Abstract base class for any entity. Provides base functionality for all entities in the game.

get_class_name(self) -> str (method)

Return the class name of this entity’s class.

get_id(self) -> str (method)

Return the single character id of this entity’s class. See constants.py for the ID value of all tiles and entities.

__str__(self) -> str (method)

Return the string representation for this Entity.

__repr__(self) -> str (method)

Return the text that would be required to make a new instance of this class that looks identical (where possible) to self.

Note: you are only required to replicate information that can be set via arguments to the __init__ method for the relevant class. For instance, in the Plant subclass of Entity described later in this document, you are not required to provide the syntax for setting the new Plant instance’s water, health, age, and repellent. Only the name needs to be communicated in the __repr__ output, because this is the only attribute that can be replicated via the Plant.__init__ method.

>>> entity = Entity()

>>> entity.get_class_name()

‘Entity’

>>> entity.get_id()

‘E’

>>> str(entity)

‘E’

>>> entity

Entity()

Plant                              (class)

Inherits from Entity

Plant is an Entity that is planted by the user. A plant has water and health points (HP) which start at 10, age starting at 0, and no repellent. A plant’s drink rate and sun level are determined by the name of the plant See constants.py for the drink rate and sun level of all plants.

__init__(self, name: str) -> None (method)

Setup the plant with a given plant name. See constants.py for the plant names.

get_name(self) -> str (method)

Return name of the plant.

get_drink_rate(self) -> float (method)

Return water drinking rate of the plant

decrease_water(self, amount: float) -> None (method)

Decrease the plants water by a specified amount.

drink_water(self) -> None (method)

Reduce water levels by plant’s drink rate. If water levels is zero (or less than zero)

the plant’s HP reduces by 1.

get_sun_levels(self) -> tuple[int, int] (method)

Return the acceptable sun level of the plant with the lower and upper range.

get_health(self) -> int (method)

Return the plant’s current HP.

add_health(self, amount: int) -> None (method)

Add to the plant’s health levels by a specified amount.

decrease_health(self, amount: int = 1) -> None (method)

Decrease the plants health by a specified amount, decrease by 1 by default.

get_water(self) -> float (method)

Return the water levels of the plant.

water_plant(self) -> None (method)

Add to the plant’s water level by 1.

set_repellent(self, applied: bool) -> None (method)

bestdaixie

评论已关闭。