Aditya Krishnamoorthy, Nicholas Perry, Rakrish Dhakal
To run the project, from the P2 directory, call
`gradle build'
'gradle run'
This method returns what is currently stored in the given Location. This could be any of the enumerated types. This implementation relies on the fact that if a given Location loc is not empty, field contains the HashSet of what is in that location. The implementation checks if the location is out of bounds, and returns a WallSet if so (walls are infinite). If field does not have the location as a key, it is an empty location, so emptySet is returned. Otherwise, what is in field is returned. The test checks the out of bounds conditional; it should return wallSet, as the walls are infinite.
This moves the ghost in question to a valid location. If it is unable to do so, false is returned. This implementation moves the ghost to the first element of the set of valid locations, returning false if the set is empty. It uses map move to move the ghost on the map, and updates the location var of the ghost. The test puts the ghost in a location on the map where it can move, and checks that ghost move returns true.
Similar to map implementation - moves to first valid location in set of valid location. Returns false with same cases. Test puts pacman in a location on map where it can move, and checks if map.move is true.
The method takes a name, location, and type and put the object specified by the name at the location. If the function is able to successfull move the object it returns true, otherwise it returns false. If the move is successful, the field
, locations
, and JComponent of the object are all be updated. The test verifies that the function returns true on a possible move.
This function returns an arraylist of possible locations that a ghost can move to from its current location. A ghost cannot move through walls, but they can move through other ghosts or a PacMan. The test verifies the number of available moves around a specified location.
This function returns an arraylist of possible locations that a pacman can move to from its current location. A pacman cannot move through walls, but they can move through ghosts or another PacMan. The test verifies the number of available moves around a specified location.
This method updates the gameOver
variable, so that when a ghost attacks PacMan, the game is finished. The test checks that when we call the function, it returns true, ensuring that the game is over.
This function checks for a ghost if PacMan is within a 1-unit radius of the ghost. The test adds PacMan at (9, 12) and a ghost at (9, 11) and asserts that pacman is indeed in range.
This function checks for PacMan if there is a ghost within a 1-unit radius of PacMan. The test adds PacMan at (9, 12) and a ghost at (9, 11) and asserts that the ghost is indeed in range.