Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. package Model;
  2.  
  3. /**
  4. * Model of a charging pod.
  5. * The charging pod charges the corresponding robot
  6. *
  7. * @author vinhhoang
  8. * @version 1.0
  9. */
  10. public class ChargingPod implements Actor{
  11. private String ID;
  12. private Location location;
  13. private int chargingSpeed;
  14. private String robotID;
  15.  
  16. /**
  17. *
  18. * @param id Unique ID of charging pod
  19. * @param location Location of the charging pod
  20. * @param chargingSpeed Amount of power-increase of the battery
  21. * @param robotID Associated robotID of the charging pod
  22. */
  23. ChargingPod(String id, Location location, int chargingSpeed, String robotID) {
  24. this.ID = id;
  25. this.location = location;
  26. this.chargingSpeed = chargingSpeed;
  27. }
  28.  
  29. public void act() {
  30. // Some code
  31. }
  32.  
  33. /**
  34. * Return the location of the charging pod
  35. * @return location chargingPod's current location
  36. */
  37. public Location getLocation() {
  38. System.out.println("Return the location of the charging pod")
  39. return location;
  40. }
  41.  
  42. /**
  43. * Compares ID of robot at chargingPod location with
  44. * robotID of chargingPod
  45. *
  46. * @param robot Robot at the chargingPod location
  47. * @return boolean true if robotID equal to chargingPod's robotID, false otherwise
  48. */
  49. public boolean checkRobotID(Robot robot) {
  50. System.out.println("Call a parameter of a Robot class get it ID"
  51. + " and compare it with the robotID with in the class.");
  52. if(robot.getUID() == robotID) {
  53. return true;
  54. }
  55. return false;
  56. }
  57.  
  58. /**
  59. * Charge battery of the robot
  60. * @param robot Robot at the chargingPod's location
  61. */
  62. public void incrementPower(Robot robot) {
  63. System.out.println("Call a parameter of a Robot class get it power field"
  64. + " and increase by the charging speed");
  65. robot.setPower(robot.getPower() + chargingSpeed);
  66. }
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement