Skip to content

Commit

Permalink
Merge pull request #87 from 2AA4-W24/varun
Browse files Browse the repository at this point in the history
added compass to keep track of current drone heading
  • Loading branch information
v5run authored Mar 3, 2024
2 parents 08e8b94 + e8fece4 commit 44d9661
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class AirDecision extends Decision {
// Command object
Command command = new Command();
Response response; // will be initialized accordidng to type -> using polymorphism
Compass direction = new Compass(); //NEED TO INITIALIZE HEADING

private int counter = 0;

Expand Down
49 changes: 49 additions & 0 deletions src/main/java/ca/mcmaster/se2aa4/island/team101/Compass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package ca.mcmaster.se2aa4.island.team101;

public class Compass {

private String direction;

protected static final String NORTH = "N";
protected static final String EAST = "E";
protected static final String SOUTH = "S";
protected static final String WEST = "W";

/*
public Compass(String init_direction){ // INITIALIZE HEADING HERE
this.direction = init_direction;
}
*/

public String left(){
switch (direction){
case NORTH:
direction = WEST;
case SOUTH:
direction = EAST;
case EAST:
direction = NORTH;
case WEST:
direction = SOUTH;
}
return direction;
}

public String right(){
switch (direction){
case NORTH:
direction = EAST;
case SOUTH:
direction = WEST;
case EAST:
direction = SOUTH;
case WEST:
direction = NORTH;
}
return direction;
}

public String forward(){
return direction;
}
}

0 comments on commit 44d9661

Please sign in to comment.