generated from 2AA4-W24/a2-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from 2AA4-W24/varun
added compass to keep track of current drone heading
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
src/main/java/ca/mcmaster/se2aa4/island/team101/Compass.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
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; | ||
} | ||
} |