// Arup Guha
// 2/24/2026
// Pacman is ALSO a Piece!!!

public class Pacman extends Piece {
	
	private String name;
	private int score;
	private int numCaptures;
	
	// Creates a new Pacman object at (x,y) with name myName.
	public Pacman(int x, int y, String myName) {
		super(x, y, 0, 0); 
		name = myName;
		score = 0;
		numCaptures = 0;
	}
	
	// Returns a String representation of this Pacman.
	public String toString() {
		return "Pacman "+name+" at "+loc+" with score "+score+" and "+numCaptures+" captures";
	}
	
	// This Pacman eats Piece p.
	public void eat(Piece p) {
		
		// One more capture.
		numCaptures++;
		
		// We get points if it's a fruit!
		if (p instanceof Fruit)
			score += ((Fruit)p).getPoints();
	}
	
	// This is how Pacman is allowed to change its vector of movement.
	
	public void incDX() {
		dir.moveBy(1,0);
	}
	
	public void decDX() {
		dir.moveBy(-1,0);
	}
	
	public void incDY() {
		dir.moveBy(0,1);
	}
	
	public void decDY() {
		dir.moveBy(0,-1);
	}

}