Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Represents a wheel.
- */
- public class Wheel {
- /** The location of the wheel. This should be a lowercase string such as "front left"*/
- String wheelLocation;
- /** The maximum HP of a wheel*/
- final int MAX_HP = 100;
- /** The HP of the wheel. It cannot exceed MAX_HP*/
- private int HP;
- /**
- * Sets the HP of the wheel.
- * HP is an integer, and the value is capped at MAX_HP
- * @param hp The HP that the wheel should be set to
- */
- public void setHP(int hp){
- if (hp>MAX_HP){
- HP = MAX_HP;
- return;
- }
- HP = hp;
- }
- /**
- * Returns the current HP of the wheel.
- * @return The wheel's HP
- */
- public int getHP(){
- return HP;
- }
- /**
- * Sets the location of the wheel. This should be a lowercase string such as "front left"
- * @param location the location of the wheel, which should be a lowercase string such as "front left"
- */
- public void setLocation(String location){
- wheelLocation = location;
- }
- /**
- * Returns the location of the tire as a string
- * @return The wheel location
- */
- public String getLocation(){
- return wheelLocation;
- }
- /**
- * Constructs the wheel with no arguments.
- * Automatically sets the HP to MAX_HP and
- * the location to a blank String.
- */
- public Wheel() {
- wheelLocation = "";
- setHP(MAX_HP);
- }
- /**
- * Constructs the wheel.
- * Automatically sets the location to a blank String.
- * @param hp the HP of the wheel, capped at MAX_HP
- */
- public Wheel(int hp){
- wheelLocation = "";
- setHP(hp);
- }
- /**
- * Constructs the wheel.
- * Automatically sets the HP to MAX_HP.
- * @param location the location of the wheel, which should be a lowercase string such as "front left"
- */
- public Wheel(String location){
- wheelLocation = location;
- setHP(MAX_HP);
- }
- /**
- * Constructs the wheel
- * @param hp the HP of the wheel, capped at MAX_HP
- * @param location the location of the wheel, which should be a lowercase string such as "front left"
- */
- public Wheel (int hp, String location){
- setHP(hp);
- wheelLocation = location;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment