ONLY HERO MONSTER AND UPGRADE NEED ANSWERS. GameElement Unlike the other classes here,GameElementis actually an interface .
Question:
ONLY HERO MONSTER AND UPGRADE NEED ANSWERS.
GameElement
Unlike the other classes here,GameElementis actually aninterface. Give it the correct name. When you edit it, add the following declarations. Note that each method is only a declaration, without any code provided.
// ---------------------------------------------------------- /**
* Get this GameElement's name.
*
* @return This object's name as a string.
*/
public String getName();
// ----------------------------------------------------------
/**
* Get this GameElement's cost in points.
*
* @return The number of points for this object.
*/
public int getPoints();
This interface requires that any class that implements it must provide getter methods to return the name and number of points associated with the object.
Unit
This class represents any kind of playable unit in the game, and will define the features that all units have in common.Unitis defined primarily by its attributes. For each of the attributes below, you must:
- Declare a field with the given name and type.
- Define a getter method (accessor) for the field.
- Define a setter method (mutator) for the field.
In addition,Unitmust implementGameElement Activity 05.
Attribute | Type | Description |
---|---|---|
name | string | The name of the unit. |
points | int | The point value of the unit. |
quality | int | The "quality" of the unit, which is a measure of its strength or capability. |
defense | int | The "defense" of the unit, which is a measure of how well it can resist damage. |
TheUnitclass must provide a constructor that takes aStringparameter representing the unit's name and anintparameter representing the unit's point value, using these to initialize the corresponding fields. The quality and defense fields should each be initialized to 2.
EnhancedUnit
Some units have special abilities.EnhancedUnitis asubclassofUnitthat supports storing this information. A special ability might be a nous that this unit provides to other units fighting with it, a special move it can perform, extra defense against certain kinds of opponents, etc.
For each of the attributes below, you must:
- Declare a field with the given name and type.
- Define a getter method (accessor) for the field.
- Define a setter method (mutator) for the field.
Note that youmay notredeclare fields with the same name as those inherited from the parent class. To access attributes of a parent class,use the appropriate getter or setter methods that are also inherited.
Attribute | Type | Description |
---|---|---|
specialRule | string | The description of this unit's special ability or properties. |
Like aUnit, theEnhancedUnitmust provide a constructor that takes aStringparameter representing the unit's name and anintparameter representing the unit's point value. The special rule should be initialized to the valuenull, a keyword in Java that indicates no object.
Hero
AHerois asubclassofEnhancedUnitthat is extra durable and capable. Further, heroes can boost the capabilities of other units close to them, so their "special rule" often includes modifiers for nearby units. When combined in a small team with other units, a hero is often the leader, inspiring their teammates to greater performance. Think of a team captain, a veteran squad leader with amazing experience and equipment, a mighty berserker, or a priestess who leads a band of healers.
Like aUnitorEnhancedUnit, theHeroclass must provide a constructor that takes aStringparameter representing the unit's name and anintparameter representing the unit's point value. However, the constructor must also set the quality and defense to 5. Remember that all fields must be private and you cannot redeclare fields in subclasses.
Monster
AMonsteris anothersubclassofEnhancedUnitthat is extra durable and capable. Think of a dragon, a giant, or a Tyranosaurus Rex playing on your team. As an enhanced unit, a monster can have a special rule that represents a special move, extra resistance to certain opponents, etc. However, unlike heroes, monsters don't inspire their teammates--perhaps their teammates are even afraid of them.
Like aUnitorEnhancedUnit, theMonsterclass must provide a constructor that takes aStringparameter representing the unit's name and anintparameter representing the unit's point value. However, the constructor must also set the quality and defense to 4.
Upgrade
AnUpgradeis the only class that is not a type of unit. Instead, in tabletop miniatures games, many players spend a lot of time collecting, building, painting, and modifying the "miniatures" that represent their units. Many minatures games provide many variations and choices for the kind of equipment a given unit can carry, with different attachments, gear, or weapons modifying the unit's abilities. These are "upgrades", usually boosting the unit's abilities in some interesting way.
However, in a miniatures game, upgrades don't come for free. Each unit is worth a certain number of points, and each upgrade usually adds to the point value of a unit. A player typically has a maximum limit on the number of points they can use to build their army. So part of the fun is picking and choosing different types of units, different types of upgrades, different heroes, and so on, trying to maximize the capability of the whole team while still falling within the allowed number of points.
TheUpgradeclass represents any kind of upgrade that can be applied to a unit in the game. Some upgrades may only be compatible with certain units, but we won't worry about that here. For this assignment, anUpgradeis defined primarily by its attributes. For each of the attributes below, you must:
- Declare a field with the given name and type.
- Define a getter method (accessor) for the field.
- Define a setter method (mutator) for the field.
In addition,Upgrademust also implementGameElement.
Attribute | Type | Description |
---|---|---|
name | string | The name (and description) of the upgrade. |
points | int | The point value of the upgrade. |
TheUpgradeclass must provide a constructor that takes aStringparameter representing the upgrade's name and anintparameter representing the upgrade's point value, using these to initialize the corresponding fields.
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall