Last active
June 28, 2017 00:27
-
-
Save mc256/2c6a627c9821b4b189e9ca83979c6eb4 to your computer and use it in GitHub Desktop.
eecs1022hints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RoomModel { // In your model .java file | |
private static final int WIDTH = 4; | |
private static final int HEIGHT = 5; | |
private int steps; //USE CONSTRUCTOR TO INITIALIZE. | |
private Position = new Position(); | |
static class Position { | |
// Not necessary to have nested class | |
// but it is a good approach | |
public int xPosition; | |
public int yPosition; | |
} | |
// YOU WILL WRITE THESE METHODS | |
public boolean canXXXX(){} //Create 4 methods for different directions | |
public void moveXXXX(){} //Create 4 methods for different directions | |
public void updateSteps(){} | |
public int getSteps(){} | |
} | |
class Controller { // In your controller .java file | |
public void onButtonClick(view View){ //Create 4 methods for each button | |
if (model.canMoveXXXX()) { | |
// the x- and y-coordinate of the robot are updated only if the robot can move (use your canGo???? | |
// methods to determine if robot can move), and | |
model.moveXXX(); | |
} | |
//the counter is incremented even if the robot cannot move in the direction corresponding to the pressed button. | |
model.updateSteps(); | |
//We want to distinguish those buttons that capture directions in which the robot can move from the buttons | |
//representing directions in which the robot cannot move. The former should be green, whereas the latter should be red. | |
updateButtonStatus(); | |
updateLabel(); | |
} | |
public void updateButtonStatus(){ | |
ButtonXXX.setBgColor((model.canMoveXXX())? Green : Red); | |
} | |
public void updateLabel(){} //method this.t(); in Prof's Webpage | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment