Skip to content

Instantly share code, notes, and snippets.

/Player.java Secret

Created May 29, 2017 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/28ada7fcfaba28ea3ca52956f5b15a98 to your computer and use it in GitHub Desktop.
Save anonymous/28ada7fcfaba28ea3ca52956f5b15a98 to your computer and use it in GitHub Desktop.
/**
* 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