Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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,

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:

  1. Declare a field with the given name and type.
  2. Define a getter method (accessor) for the field.
  3. 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Usability

Authors: Jakob Nielsen, Raluca Budiu

1st Edition

0133122131, 9780133122138

More Books

Students explore these related Programming questions