Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. class RoomModel { // In your model .java file
  2. private static final int WIDTH = 4;
  3. private static final int HEIGHT = 5;
  4.  
  5. private int steps; //USE CONSTRUCTOR TO INITIALIZE.
  6. private Position = new Position();
  7.  
  8. static class Position {
  9. // Not necessary to have nested class
  10. // but it is a good approach
  11. public int xPosition;
  12. public int yPosition;
  13. }
  14.  
  15. // YOU WILL WRITE THESE METHODS
  16. public boolean canXXXX(){}
  17. public void moveXXXX(){}
  18. public void updateSteps(){}
  19. public int getSteps(){}
  20. }
  21. class Controller { // In your controller .java file
  22. public void onButtonClick(view View){
  23. if (model.canMoveXXXX()) {
  24. // the x- and y-coordinate of the robot are updated only if the robot can move (use your canGo????
  25. // methods to determine if robot can move), and
  26. model.moveXXX();
  27. }
  28. //the counter is incremented even if the robot cannot move in the direction corresponding to the pressed button.
  29. model.updateSteps();
  30. //We want to distinguish those buttons that capture directions in which the robot can move from the buttons
  31. //representing directions in which the robot cannot move. The former should be green, whereas the latter should be red.
  32. updateButtonStatus();
  33. updateLabel();
  34. }
  35. public void updateButtonStatus(){
  36. ButtonXXX.setBgColor((model.canMoveXXX())? Green : Red);
  37. }
  38. public void updateLabel(){} //method this.t(); in Prof's Webpage
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement