Question: 1. Create a new Java program which implements a simple PacMan-type text game which contains the following functionality: A) At program startup, constructs and displays
1. Create a new Java program which implements a simple PacMan-type text game which contains the following functionality: A) At program startup, constructs and displays a 2-dimensional grid with the size dynamically specified by the user (X and Y sizes can be different). Places the PacMan in the upper-left corner of the grid facing left All grid cells should have the empty cell character of . except for the start position of the PacMan which will have the appropriate PacMan symbol (see below). Also 20% of your grid should contain cookies randomly located on the grid except for the initial PacMan position. A menu of commands then the grid must be displayed. B) Use these symbols for the grid: 1. Cookie symbol shows were cookies are in the grid ('O') 2. Empty symbol shows empty unvisited grid cells ('.') (dot) 3. Visited symbol shows grid cells where the PacMan has visited (' ') (space) 4. PacMan symbol depends on the current PacMan facing direction. 1. Left > 2. Up V 3. Right < 4. Down ^ C) A menu of commands must be provided and must be displayed when appropriate. At a minimum the menu should consists of the following commands: 1. Turn Left turns the PacMan left but the PacMan stays in its current location 1. Current: up, new: left 2. Current: right, new up 3. Current: down, new right 4. Current: left, new down 2. Turn Right turns the PacMan right but the PacMan stays in its current location 1. Current: up, new: right 2. Current: right, new down 3. Current: down, new left 4. Current: left, new up 3. Move Moves the PacMan one grid location in the facing direction if possible. 4. Exit exits the program displaying the game statistics of the number of total moves and the average number of moves per cookie obtained. 2. The main processing cycle is the following: A) The grid must be displayed after each command showing the effects of the command. B) Optionally display the list of commands C) Display the grid D) Accept user input. Code will be provided for reading user input. 1. If an invalid command is entered, an appropriate error message should be displayed and the menu of commands and grid gets redisplayed. An invalid command does not count as a command in the statistics. 2. Process the command and add one to the number of commands entered if it is an action command (move or turn). 3. If the user enters the Exit command, the program will display the number of commands and the average number of commands per cookie. E) If the resulting move places the PacMan over a cookie, indicate the cookie was eaten and add one to the number of cookies eaten for the program statistics.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
