// Arup Guha
// 2/24/2026
// Pacman is ALSO a Piece!!!
// Edited on 3/8/2026 for Abstract class lecture

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( new Position(x, y), new Position(0, 0)); 
		name = myName;
		score = 0;
		numCaptures = 0;
	}
	
	// Returns a String representation of this Pacman.
	public String toString() {
		return "Score = "+score;
	}
	
	// This Pacman eats Piece p.
	public boolean eat(Piece p) {
		
		// Got eaten!
		if (p instanceof Ghost)
			return false;
		
		// One more capture.
		if (p instanceof Dot)
			numCaptures++;
		
		// We get points if it's a fruit!
		if (p instanceof Fruit)
			score += ((Fruit)p).getPoints();
		
		// We're still alive if we get here.
		return true;
	}
	
	// This is the shape of PacMan!
	public char getCode() {
		return 'C';
	}
}