[Solved]Java Programming Snake Game Question Long Worth 5 Questions Post Question 5 Times Link 5 Q Q37085359
Java Programming, snake game. As this question is very long, itwill be worth 5 questions, I will post this same question 5 times,with the link to all 5 questions in each question.
https://www.chegg.com/homework-help/questions-and-answers/java-programming-snake-game-question-long-worth-5-questions-post-question-5-times-link-5-q-q37085359
https://www.chegg.com/homework-help/questions-and-answers/java-programming-snake-game-question-long-worth-5-questions-post-question-5-times-link-5-q-q37085350
https://www.chegg.com/homework-help/questions-and-answers/java-programming-snake-game-question-long-worth-5-questions-post-question-5-times-link-5-q-q37085347
https://www.chegg.com/homework-help/questions-and-answers/java-programming-snake-game-question-long-worth-5-questions-post-question-5-times-link-5-q-q37085340
https://www.chegg.com/homework-help/questions-and-answers/java-programming-snake-game-question-long-worth-5-questions-post-question-5-times-link-5-q-q37085338
In this lab, you will begin work on a snake game. Here you will beworking on internal logic
and bookkeeping. This must function independently of the game GUI,which you will write in
the next assignment.
Game Description
In a snake game such as Nibbles (seehttps://en.wikipedia.org/wiki/Nibbles_(video_game))
the objective is to navigate a snake through a walled space (ormaze), consuming food along the
way. The user must avoid colliding with walls or the snake’sever-growing body. The length
of the snake increases each time food is consumed, so thedifficulty of avoiding a collision increases
as the game progresses.
Problem Specification
You are going to create a GameManager class to handle your snake,wall, and food bookkeeping.
You will probably want some additional classes/interfaces toaccomplish this, but I leave that
design up to you. You will demonstrate its functionality in aGameManagerTester class. The
GameManager and related classes should be independent of any futureGUI code.
You will configure your GameManager object by reading in a levelconfiguration file.
Level File Format
A level configuration file specifies the size of the game area andthe locations of the walls. It is
a text file of numbers separated by whitespace.
The first line in the file contains two integer values specifyingthe width and height of the game
area. If there is additinal data on this line, it may beignored.
The following lines (if any) specify the walls. A wall linecontains contains four integer values:
the first two are the x and y position of the upper left corner ofthe wall, the second two are the
x and y position of the the lower right corner of the wall. Ifthere is additional data on this line,
it may be ignored.
If you want to add additional information to your levelconfiguration files, you may do so, but
you must still be able to handle the basic file format describedabove. I have provided you with
some sample input files on the course website.
GameManager class
Although you may chose to use one fixed level design for your finalgame, your class should
be able to handle arbitrary positive values for width and height ofthe playing area.
Your class must provide the following functionality.
Construct a new manager of a given size.
Add walls in specified locations, as read from a levelconfiguration file.
Add at least one snake at some unoccupied location.
Add at least one food item at some random unoccupiedlocation.
– The final game will use random placement for the food, but forthis test program you
should have reproducible results each time it is run.
– One simple way to have “random” behaviour that can be repeated isto use a Random
object that has been initialized with a fixed seed.
Override toString in your GameManager class to provide a stringrepresentation of your
board that can be printed to the terminal for debugging and testingpurposes. Make it
clear what locations are walls, food, snake, and empty space.
Update snake position one step and check for collisions.
– If the snake collides with food, the snake eats the food (removesit from game) and
grows in length. A new food item is placed in at some randomunoccupied location.
– If the snake collides with a wall or its own body, detect thissomehow. In the full
game, the game would be over (or maybe the player would lose alife, depending on
your game design), but for the testing code, we’ll just report thecollision.
I fully expect that much of the GameManager logic will be handledby additional game object
classes, such as Snake, Wall, and Food. You may want to make someor all of these classes
extend a common abstract parent or implement a commoninterface.
GameManagerTester class
The purpose of this testing class is to demonstrate to us that yourgame manager works correctly,
so you need to put it through its paces by creating andmanipulating GameManager objects
as outlined below.
You should create at least two GameManager objects with separatesizes and wall configurations.
At least one of them must be initialized from a level configurationfile. Demonstrate
that they operate independently of each other. (I want to make sureyou aren’t locked into
just one configuration and that you aren’t making things staticinappropriately.)
Add at least one food item and snake to each manager.
Test moving the snake around in each manager:
– Print out the string representation of the manager before youbegin.
– Update snake position and print the manager after theupdate.
– Demonstrate changing snake direction.
– Demonstrate eating food and show that snake grows.
– After testing the each manager, continue testing with the firstmanager again to
demonstrate that it is independent of the second.
– Demonstrate collisions of the snake with a wall and the snakewith itself.
Don’t just copy and paste the same test code for each manager. Youshould try to structure
your code sensibly with methods rather than writing one giant mainmethod.
Your testing output should come from GameManagerTester, notGameManager or any other
game object classes that you may write. Don’t put console output inthe middle of your
game logic.
I am providing you with example output from my testing code to giveyou an idea what I’m
expecting this to look like.



Maze Examples: maze-simple maze-stripes maze-zigzag-large maze-zigzag-small 20 11 0 0 19 0 maze-cross 20 20 0 0 19 0 0 19 19 190 10 19 10 5 26 15 0 1 0 18 19 1 19 1819 0 19 10 15 2 32 15 70 0 70 44 9 3 10 16 3 9 8 10 11 9 16 10 35 19 2 2 2 15 71 45 0 0 70 0 0 44 70 44 0 0 0 44 50 30 0 0 49 0 0 29 49 29 0 0 0 29 49 0 49 29 10 1 10 24 20 6 20 29 30 1 30 24 40 6 40 29 9 2 12 15 0 1 0 10 10 1 10 35 20 9 20 43 30 1 30 35 40 9 40 43 50 1 50 35 60 9 60 43 4 5 15 5 Ga s: testing map from maze-simple.txt snake changes direction to UP snake changes direction to LEFT snake eats food meManagerTester Output Example snake changes direction to LEFT xX xX… .SsssX testing map from maze-cross.txt snake changes direction to DOWN xX SssX X.. xX…SssssX x X GameManagerTester Output Examples Cont..: snake changes direction to UP snake eats food .f.X X xX xX xX xX x X. snake changes direction to LEFT resume testing map from maze-simple.txt snake changes direction to RIGHT snake collides with wall X..555ss X..XXXxXxXXXX..X snake changes direction to UP snake collides with self X.·sss Show transcribed image text Maze Examples: maze-simple maze-stripes maze-zigzag-large maze-zigzag-small 20 11 0 0 19 0 maze-cross 20 20 0 0 19 0 0 19 19 190 10 19 10 5 26 15 0 1 0 18 19 1 19 1819 0 19 10 15 2 32 15 70 0 70 44 9 3 10 16 3 9 8 10 11 9 16 10 35 19 2 2 2 15 71 45 0 0 70 0 0 44 70 44 0 0 0 44 50 30 0 0 49 0 0 29 49 29 0 0 0 29 49 0 49 29 10 1 10 24 20 6 20 29 30 1 30 24 40 6 40 29 9 2 12 15 0 1 0 10 10 1 10 35 20 9 20 43 30 1 30 35 40 9 40 43 50 1 50 35 60 9 60 43 4 5 15 5
Ga s: testing map from maze-simple.txt snake changes direction to UP snake changes direction to LEFT snake eats food meManagerTester Output Example snake changes direction to LEFT xX xX… .SsssX testing map from maze-cross.txt snake changes direction to DOWN xX SssX X.. xX…SssssX x X
GameManagerTester Output Examples Cont..: snake changes direction to UP snake eats food .f.X X xX xX xX xX x X. snake changes direction to LEFT resume testing map from maze-simple.txt snake changes direction to RIGHT snake collides with wall X..555ss X..XXXxXxXXXX..X snake changes direction to UP snake collides with self X.·sss
Expert Answer
Answer to Java Programming, snake game. As this question is very long, it will be worth 5 questions, I will post this same questio… . . .
OR

