Project 1- Pacman Group Members: Sonia Sandler, Janaki Patel, Roshan Mathew
Running the game:
javac -cp "src/" src/*.java
java -cp "src/" StartMenuFunctions
Pacman:
- get_valid_moves() - This function takes into account PacMan's current position and checks for Walls (internally or along the game board dimensions) to see if it can move in a direction. If there is no Wall, it adds the new Location into an ArrayList of Locations. A PacMan can move either up, down, left, or right.
- move() - This function uses get_valid_moves() and checks if it is empty. If it is it returns false and if it isn't it returns true. The test adds a cookie and pacman to the frame and asserts that the pacman has space to move.
- is_ghost_in_range()- this method checks to see if there is a ghost next to the current object (up, down, right, left)
- consume()- this function checks for power cookie within range and calls eatCookie if valid
Ghost
- get_valid_moves() - This function takes into account a Ghost's current position and checks for Walls (internally or along the game board dimensions) to see if it can move in a direction. If there is no Wall, it adds the new Location into an ArrayList of Locations. A Ghost can move either up, down, left, or right.
- move() - This function uses get_valid_moves() and checks if it is empty. If it is it returns false and if it isn't it returns true. The test adds a ghost and pacman to the frame and asserts that the ghost has space to move.
- is_pacman_in_range() - this method checks to see if there is a pacman next to the current object (up, down, right, left)
- attack() - checks to see if pacman is within attack range. Returns true or false accordingly
Map
- move(String name, Location loc, Type type) - This function takes a name, location, and Map.Type and if the Type is GHOST or PACMAN, since they are the only Types that can move, it attempts to move them and returns True. If the type is anything else, then it returns False.
- getLoc(Location loc) - This function checks the loc HashSet to find the corresponding type. If it is null, returns the emptySet else it returns the type. The test adds a ghost and a pacman and then asserts that the type at those locations correspond to what was put there.
- attack(String name) - this method is supposed to be called by the Ghost class when there is a successful attack. It updates gameOver to be true
- eatCookie(String Name)- This function controls pacman eating a cookie. Updates the cookies, field, location and componenents accordingly.