heroofhyla

Untitled

Oct 11th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. /**
  2. * Represents a wheel.
  3. */
  4. public class Wheel {
  5. /** The location of the wheel. This should be a lowercase string such as "front left"*/
  6. String wheelLocation;
  7. /** The maximum HP of a wheel*/
  8. final int MAX_HP = 100;
  9. /** The HP of the wheel. It cannot exceed MAX_HP*/
  10. private int HP;
  11.  
  12. /**
  13. * Sets the HP of the wheel.
  14. * HP is an integer, and the value is capped at MAX_HP
  15. * @param hp The HP that the wheel should be set to
  16. */
  17. public void setHP(int hp){
  18. if (hp>MAX_HP){
  19. HP = MAX_HP;
  20. return;
  21. }
  22. HP = hp;
  23. }
  24.  
  25. /**
  26. * Returns the current HP of the wheel.
  27. * @return The wheel's HP
  28. */
  29. public int getHP(){
  30. return HP;
  31. }
  32.  
  33. /**
  34. * Sets the location of the wheel. This should be a lowercase string such as "front left"
  35. * @param location the location of the wheel, which should be a lowercase string such as "front left"
  36. */
  37. public void setLocation(String location){
  38. wheelLocation = location;
  39. }
  40.  
  41. /**
  42. * Returns the location of the tire as a string
  43. * @return The wheel location
  44. */
  45. public String getLocation(){
  46. return wheelLocation;
  47. }
  48.  
  49.  
  50. /**
  51. * Constructs the wheel with no arguments.
  52. * Automatically sets the HP to MAX_HP and
  53. * the location to a blank String.
  54. */
  55. public Wheel() {
  56. wheelLocation = "";
  57. setHP(MAX_HP);
  58. }
  59.  
  60. /**
  61. * Constructs the wheel.
  62. * Automatically sets the location to a blank String.
  63. * @param hp the HP of the wheel, capped at MAX_HP
  64. */
  65. public Wheel(int hp){
  66. wheelLocation = "";
  67. setHP(hp);
  68. }
  69.  
  70. /**
  71. * Constructs the wheel.
  72. * Automatically sets the HP to MAX_HP.
  73. * @param location the location of the wheel, which should be a lowercase string such as "front left"
  74. */
  75. public Wheel(String location){
  76. wheelLocation = location;
  77. setHP(MAX_HP);
  78. }
  79.  
  80. /**
  81. * Constructs the wheel
  82. * @param hp the HP of the wheel, capped at MAX_HP
  83. * @param location the location of the wheel, which should be a lowercase string such as "front left"
  84. */
  85. public Wheel (int hp, String location){
  86. setHP(hp);
  87. wheelLocation = location;
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment