forked from helloplz/MazeBuilder
-
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.
Added SimpleLocation. Finished board rendering.
- Loading branch information
1 parent
a2b3b37
commit 733e1e2
Showing
3 changed files
with
137 additions
and
49 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
38 changes: 38 additions & 0 deletions
38
Mazebuilder/src/com/mazebuilder/gameplay/SimpleLocation.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,38 @@ | ||
package com.mazebuilder.gameplay; | ||
|
||
public final class SimpleLocation implements Location { | ||
|
||
private final int row, column; | ||
|
||
public SimpleLocation(int row, int column) { | ||
this.row = row; | ||
this.column = column; | ||
} | ||
|
||
@Override | ||
public int getRow() { | ||
return row; | ||
} | ||
|
||
@Override | ||
public int getColumn() { | ||
return column; | ||
} | ||
|
||
@Override | ||
public Location move(Direction d) { | ||
switch (d) { | ||
case DOWN: | ||
return new SimpleLocation(row + 1, column); | ||
case UP: | ||
return new SimpleLocation(row - 1, column); | ||
case LEFT: | ||
return new SimpleLocation(row, column - 1); | ||
case RIGHT: | ||
return new SimpleLocation(row, column + 1); | ||
default: | ||
throw new RuntimeException("Unknown direction " + d.toString()); | ||
} | ||
} | ||
|
||
} |
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