public class Dir
extends java.lang.Object
| Constructor and Description |
|---|
Dir(char dir)
Construct a Dir object.
|
| Modifier and Type | Method and Description |
|---|---|
char |
getMoveTowards(Pos mypos,
Pos target)
Returns a "move" (i.e.
|
char |
moveToFace(char dir) |
static Dir |
read(java.util.Scanner sc)
Read a Dir object (as N,E,S,W) from Scanner.
|
Pos |
stepFrom(Pos p)
Returns the position resulting from one step in this direction from position p.
|
java.lang.String |
toString()
Represents the direction as one of the strings "N", "E", "S", or "W".
|
Dir |
turn(char move)
Returns the direction you would be heading after making "move" from the current direction.
|
public Dir(char dir)
dir - The direction as character N, E, S or W.public static Dir read(java.util.Scanner sc)
sc - The scanner the direction character is read from.public Pos stepFrom(Pos p)
p - The point that the one step starts from.public char getMoveTowards(Pos mypos, Pos target)
mypos - The position you're currently at.target - The position you'd like to get to.public char moveToFace(char dir)
public Dir turn(char move)
move - One of L=left, R=right, F=forwards, B=backwards.public java.lang.String toString()
toString in class java.lang.Object