-
-
Save anonymous/28ada7fcfaba28ea3ca52956f5b15a98 to your computer and use it in GitHub Desktop.
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
/** | |
* Write a description of class Player here. | |
* | |
* @author (your name) | |
* @version (a version number or a date) | |
*/ | |
public class Player | |
{ | |
// instance variables - replace the example below with your own | |
private int x; | |
private int y; | |
private int collectedDots; | |
// /** | |
// * Constructor for objects of class Player | |
// */ | |
public Player(int initialX, int initialY) | |
{ | |
x = initialX; | |
y = initialY; | |
collectedDots = 0; | |
} | |
public void move(int dx, int dy) | |
{ | |
x = x + dx; | |
y = y + dy; | |
} | |
public String toString() | |
{ | |
return "Player[" + | |
collectedDots + "]" + | |
Util.objectStr(x, y, true); | |
} | |
public void collect() | |
{ | |
if | |
++collectedDots; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment