Reference no: EM132391653
FIT9131 - Programming foundations in Java Assignment - 256 With Arraylists, Monash University, Australia
The assignment must be done using the BlueJ environment.
The Java source code for this assignment must be implemented according to the Java Coding Standards for this unit.
Completion of this assignment contributes towards the following learning outcomes:
1. Design, construct, test and document small computer programs using Java;
2. Interpret and demonstrate software engineering principles of maintainability, readability, and modularisation;
3. Explain and apply the concepts of the "object-oriented" style of programming.
Specification -
In this assignment you will write a program to play the game of 256 With Arraylists. The objective of the game is for the player to keep adding three randomly provided multiples of a number, to attempt to get the total score of 256 or higher. The game is a modified version which allows the player to use up to two arraylists as buffers which can be used to store the numbers and retrieve the numbers. This section specifies the required functionality of the program. Only a text interface is required for this program; however, more marks will be gained for a game that is easy to follow with clear information and error messages to the player.
256 With Arraylists (D Level Assignment) -
The game begins with the program reading the allowed multiples from a file called "multiples.txt". (This file is available on moodle). The file will only contain ONE set of mutliples. These are the three numbers which will be randomly provided to the user during the game. For e.g. 2, 4, and 8. The game will operate using one arraylist as a buffer instead of a grid. The maximum number of elements which can be stored in the arraylist is 5. Below is a depiction on the game layout (for illustration only):
The game sequence is as follows:
1. The game starts by registering a player to play the game.
2. The Arraylist buffer (b1) is empty.
3. The game then provides a random multiple to the player which is stored in the game total from the available multiples.
4. The player can then perform the following actions:
Split:
- This allows the player to move the number from the game total (t) and add it to the arraylist buffer (b1).
- A new random multiple is then generated and put in the game total (t)
- The game then continues from point 3 above.
Merge:
- This allows the player to merge the number in the game total box with a matching number in the arraylist at any position. The total is then put in the game total box and the number which is added is then removed from the arraylist.
- After the total is added, the game total (t) now shows the new number. No new random number is generated and the game goes back to point 4 above to allow the player to continue.
5. The game ends when either of the following occur:
- The game total (t) reaches the total of 256 or higher.
- The arraylist buffer (b1) has reached the maximum limit of 5 numbers and no more numbers can be stored and none of the existing numbers can be merged to the game total (t).
At the end of the game, the program will write the final outcome to the file "outcome.txt" which will show the player name and the highest score achieved.
256 With Arraylists (HD Level Assignment) -
The game begins with the program reading the allowed multiples from a file called "multiples.txt". (This file is available on moodle). The file will only contain MANY sets of mutliples. The user can choose which multiple they would like to use when playing the game. These are the three numbers which will be randomly provided to the user during the game. The game will operate using TWO arraylist as buffers instead of a grid. The maximum number of elements which can be stored in thefirst arraylist is 5. The maximum number of elements which can be stored in the second arraylist is 3. The game also allows the user to set the game total up to which the game will be played. Below is a depiction on the game layout.
The game sequence is as follows:
1. The game starts by registering a player to play the game.
2. The player is prompted to enter the game total upto which the game will be played. The game total must be greater than 32 and a multiple of 8.
3. The player is then prompted to select from the possible list of multiple with which to play the game. (These have been read from the file).
4. Both the Arraylist buffers (b1 and b2) are empty.
5. The game then provides a random multiple to the player which is stored in the game total.
6. The player can then perform the following actions:
Split Right
- This allows the player to add the game total (t) number to the right arraylist buffer (b2)
- A new random multiple is then generated and put in the game total (t)
- The game then continues from point 5 above.
Merge Right
- This allows the player to merge the number in the game total box with a matching number in any position in the right arraylist buffer. The total is then put in the game total box and the number is removed from the arraylist.
- After the total is added, the game total (t) now shows the new number. No new random number is generated and the game goes back to point 6 above to allow the player to continue.
Split Left
- This allows the player to add the game total (t) number to the left arraylist buffer (b1)
- A new random multiple is then generated and put in the game total (t)
- The game then continues from point 5 above.
Merge Left
- This allows the player to merge the number in the game total box with a matching number in any position in the left arraylist buffer. The total is then put in the game total box and the number is removed from the arraylist.
- After the total is added, the game total (t) now shows the new number. No new random number is generated and the game goes back to point 6 above to allow the player to continue.
7. The game ends when either of the following occur:
- The game total (t) reaches the total of whatever the user entered in point 2 above or higher.
- The arraylist buffers (b1 and b2) have reached the maximum size limit allowed (depending on the difficulty level) and no more numbers can be stored and none of the existing numbers can be merged to the game total (t).
At the end of the game, the program will write the final outcome to the file "outcome.txt" which will show the player name and the highest score achieved.
The following are some of the requirements for the game:
- Player name must be between 3 and 10 characters, cannot be blank and cannot contain only spaces.
- The arraylist buffers will not allow more elements to be stored beyond the assigned size limit (defined by the difficulty level).
Requirements - You MUST show your tutor the D level version of the assignment prior to submitting the HD Level. To do so, you may make a copy of your D level assignment which can be shown to your tutor during your scheduled tutorial.
Program design - Your program must consist of at least the following classes: Game, Buffer, Multiple, and RNG. A more scalable design with additional support classes which can be reused will get more marks. The following is the proposed class diagram for the program. The remainder of this section gives details of these classes. There are suggested fields for each class. If you include any extra fields then you must be able to justify these. You may want to include comments in your program to state any assumptions made.
Note - Do this assignment completely adhering to the requirements! And develop a test strategy for the buffer class.
Attachment:- Programming foundations in Java Assignment File.rar