Skip to main content
留学咨询

FIT9131Assignment2课业解析

By May 15, 2020No Comments

FIT9131Assignment2课业解析题意: Java实现一个名为 256 With Arraylists的游戏 解析:  游戏设计: 一、玩家注册,开始游戏  二、从multiples.txt文件中读取一个数,存储在Game Total中并显示  三、缓冲区ArrayList大小为5,初始为空  四、在游戏结束前,每一步玩家都有以下两种选择:
一、取出数
1、从Game Total中把数取出来存到ArrayList中
2、Game Total删除原来的数,并从multiples.txt中读取下一个数
3、判断结束条件,不满足则游戏从第四步继续进行
二、合并数
1、如果Game Total新读取的数和ArrayList中的某个数,把ArrayList的数和
Game Total的数相加,和存在Game Total中并删除ArrayList中的数。
2、判断结束条件,不满足则游戏从第四步继续进行  五、游戏结束条件
1、Game Total >= 256
2、ArrayList满了,且没有相同的数供合并
流程图
未完~
主要类
Game:
程序的主类,允许玩家开始游戏,处理输入和输出。具备以下属性:PlayerName 存储玩家名字(3~10个字符长度,不允许有空格) Game Total 游戏最重要的数字
Buffer:
描述一个arraylist存储的缓冲区,属性包括存储倍数类multiple的arraylist以及arraylist允许存储的最大数量。
Multiples:
存储int类型的值,代表游戏使用的数字。 涉及知识点: Java 面向对象式编程,arraylist,文本读取更多可加微信讨论微信号:IT_51zuoyejunpdf
FIT9131 Semester 2 2019 Assignment 2Page 1 of 8WithArraylistsIntroductionThis document specifies the programming component of Assignment 2. This component is due by11pm Saturday of Week 12 (26th October, 2019). Heavy penalties will apply for late submission.This is an individual assessment task and must be your own work. You must attribute the source ofany part of your code which you have not written yourself. Please note the section on plagiarism inthis document.The assignment must be done using the BlueJ environment.The Java source code for this assignment must be implemented according to the Java CodingStandards for this unit.Any points needing clarification may be discussed with your tutor in the lab classes.Completion of this assignment contributes towards the following FIT9131 learning outcomes:1. design, construct, test and document small computer programs using Java;2. interpret and demonstrate software engineering principles of maintainability, readability, andmodularisation;3. explain and apply the concepts of the “object-oriented” style of programming.SpecificationIn this assignment you will write a program to play the game of 256 With Arraylists. The objective ofthe game is for the player to keep adding three randomly provided multiples of a number, to attemptto get the total score of 256 or higher. The game is a modified version which allows the player to useup to two arraylists as buffers which can be used to store the numbers and retrieve the numbers. Thissection specifies the required functionality of the program. Only a text interface is required for thisprogram; however, more marks will be gained for a game that is easy to follow with clearinformation and error messages to the player.256FIT9131 Semester 2 2019 Assignment 2Page 2 of 8256 With Arraylists (D Level Assignment – Max Mark 79)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 threenumbers which will be randomly provided to the user during the game. For e.g. 2, 4, and 8. The gamewill operate using one arraylist as a buffer instead of a grid. The maximum number of elements whichcan 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 game then provides a random multiple to the player which is stored in the game totalfrom the available multiples..3. The Arraylist buffer (b1) is empty.4. The player can then perform the following actions:o Split: This allows the player to move the number from the game total (t) and add it tothe arraylist buffer (b1). A new random multiple is then generated and put in the game total (t) The game then continues from point 4 above.o Merge: This allows the player to merge the number in the game total box with amatching number in the arraylist at any position. The total is then put in thegame total box and the number which is added is then removed from thearraylist. After the total is added, the game total (t) now shows the new number. No newrandom number is generated and the game goes back to point 4 above toallow the player to continue.5. The game ends when either of the following occur:o The game total (t) reaches the total of 256 or higher.o The arraylist buffer (b1) has reached the maximum limit of 5 numbers and no morenumbers can be stored and none of the existing numbers can be merged to the gametotal (t).At the end of the game, the program will write the final outcome to the file “outcome.txt” which willshow the player name and the highest score achieved.GameTotal(t)ArrayListBuffer 1(b1)FIT9131 Semester 2 2019 Assignment 2Page 3 of 8256 With Arraylists (HD Level Assignment – Max Mark 100)Note: You may complete parts of the HD level to score more marks on the 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 MANY sets of mutliples. The user canchoose which multiple they would like to use when playing the game. These are the three numberswhich will be randomly provided to the user during the game. The game will operate using TWOarraylist 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 adepiction 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 player is prompted to enter the game total upto which the game will be played. The gametotal 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 thegame. (These have been read from the file).4. The game then provides a random multiple to the player which is stored in the game total.5. Both the Arraylist buffers (b1 and b2) are empty.6. The player can then perform the following actions:o Split Right () This allows the player to add the game total (t) number to the right arraylistbuffer (b2) A new random multiple is then generated and put in the game total (t) The game then continues from point 4 above.o Merge Right () This allows the player to merge the number in the game total box with amatching number in any position in the right arraylist buffer. The total isthen 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 newrandom number is generated and the game goes back to point 4 above toallow the player to continue.o Split Left () This allows the player to add the game total (t) number to the left arraylistbuffer (b1)GameTotal(t)ArraylistBuffer (b1)ArraylistBuffer (b2)FIT9131 Semester 2 2019 Assignment 2Page 4 of 8 A new random multiple is then generated and put in the game total (t) The game then continues from point 4 above.o Merge Left () This allows the player to merge the number in the game total box with amatching number in any position in the left arraylist buffer. The total is thenput 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 newrandom number is generated and the game goes back to point 4 above toallow the player to continue.7. The game ends when either of the following occur:o The game total (t) reaches the total of 256 or higher.o The arraylist buffers (b1 and b2) have reached the maximum limit of 5 numbers andno more numbers can be stored and none of the existing numbers can be merged tothe game total (t).At the end of the game, the program will write the final outcome to the file “outcome.txt” which willshow 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 onlyspaces. The arraylist buffers will not allow more elements to be stored beyond the assigned size limit.Hints and SuggestionsYour assignment may want to use pass by reference to achieve a well-designed program.Additionally, should your program wish to accept only String inputs from the user, you may want tolook up the Integer.parseInt() method which belongs to the Integer class. This can be used alongwith exception handling to ensure your program doesn’t crash.RequirementsYou 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 duringyour scheduled tutorial.FIT9131 Semester 2 2019 Assignment 2Page 5 of 8Gameplay Example (HD Level Only)The following shows a single game play using the multiples 2, 4, and 8. And the winning game totalis going to be 16.Step 1 –
Game begins and generates a randomnumber in the game total (t). The user selectsSplit Left. The game will then moves the currentgame total (t) and adds it to the arraylist buffer(b1). A new random number is then generatedand stored in the game total (t)Step 2 – The user selects Split Left again. Thegame then moves the current game total (t) andadds it to the arraylist buffer (b1). A new randomnumber is then generated and stored in the gametotal (t)Step 3 – User selects Split Right. The game thenmoves the current game total (t) and adds it to thearraylist buffer (b1). b1 now has 2 elementsstored in there. A new random number is thengenerated and stored in the game total (t)Step 4 – User selects Merge Left. The game thensearches the arraylist buffer (b1) for a valuewhich matches that in the game total (t). If found,both numbers are added, and the matchingelement in the arraylist is deleted.Step 5 – User selects Merge Left again. The gamethen searches the arraylist buffer (b1) for a valuewhich matches that in the game total (t). If found,both numbers are added, and the matchingelement in the arraylist is deleted.Step 6 – Player has reached the desired total of 16(for this illustration example only). So the gameends. The system displays that the player wins.FIT9131 Semester 2 2019 Assignment 2Page 6 of 8Program designYour program must consist of at least the following classes: Game, Buffer, Multiple, and RNG. Amore scalable design with additional support classes which can be reused will get more marks. Thefollowing is the proposed class diagram for the program.The remainder of this section gives details ofthese classes. There are suggested fields for each class. If you include any extra fields then you mustbe able to justify these. You may want to include comments in your program to state any assumptionsmade.Game:The main class of the program. It will allow the user to start the game. It generally handles all theinputs and outputs to the user unless another utility class has been included to do this. It has thefollowing attributes – PlayerName which store the players name which must be between 3 and 10characters long and cannot be blank or all spaces; and gameTotal which indicates the game total uptowhich the game will be played. The HD level of the assignment has one additional attributes,multipleList – which stores the possible multiples with which the game can be played read from thefile. (If you have difficulty applying this concept, discuss alternative approaches with your tutor).Buffer:This class describes a single arraylist buffer for the game. The attribute includes an arraylist whichstores objects of the multiple class, and an integer which stores the maximum number of elementswhich can be stored in the arraylist buffer.Multiples:This class stores an integer value for a given multiple which is used in the game.RNG:An object of the RNG class will generate a random number from a minimum value to a maximumvalue. It will have two fields, maximumValue – maximum value of the random number, andminimumValue – minimum value of the random numberFIT9131 Semester 2 2019 Assignment 2Page 7 of 8Test StrategyUsing the template discussed in Week 7’s lecture, your assignment must also provide a detailed teststrategy for the Buffer class only.AssessmentProgramming Task Assessment (20%)Assessment for this component will be done via an interview with your tutor.The marks for your program code will be allocated as follows:• 10% – Test Strategy for the Buffer class only.• 35% – Object-oriented design quality. This will be assessed on appropriate implementation ofclasses, fields, constructors, methods and validation of the object’s state and adherence toJava coding standards• 55% – Program functionality in accordance to the requirements.You must submit your work by the submission deadline on the due date (a late penalty of 20% perday, inclusive of weekends, of the possible marks will apply – up to a maximum of 100%). There willbe no extensions – so start working on it early.Marks will be deducted for untidy/incomplete submissions, and non-conformances to the FIT9131Java Coding Standards.Please note that your program code will be submitted to a code similarity checker.InterviewYou will be asked to demonstrate your program at an “interview” following the submission date. Atthe interview, you will be asked to explain your code/design, modify your code, and discuss yourdesign decisions and alternatives. Marks will not be awarded for any section ofcode/design/functionality that you cannot explain satisfactorily (the marker may also delete excessivein-code comments before you are asked to explain that code). In other words, you will be assessed onyour understanding of the code, and not on the actual code itself.Interview times will be arranged in the tutorial labs in Week 12. The interviews will take place inweek 14. It is your responsibility to attend the lab and arrange an interview time with your tutor. Anystudent who does not attend an interview will receive a mark of 0 for the assignment.Submission RequirementsThe assignment must be uploaded to Moodle by 11pm Saturday of Week 12 (26th October, 2019).The submission requirements for Assignment 2 are as follows:A .zip file uploaded to Moodle containing the following components: the BlueJ project you created to implement your assignment. a completed Assignment Cover Sheet. This will be available for download from the unit’sMoodle site before the submission deadline. You simply complete the editable sections of thedocument, save it, and include it in your .zip file for submission.FIT9131 Semester 2 2019 Assignment 2Page 8 of 8The .zip file should be named with your Student ID Number. For example, if your id is 12345678,then the file should be named 12345678_A2.zip. Do not name your zip file with any other name.It is your responsibility to check that your ZIP file contains all the correct files, and is not corrupted,before you submit it. If you tutor cannot open your zip file, or if it does not contain the correct files,you will not be assessed.Marks will be deducted for any of these requirements that are not complied with.Warning: there will be no extensions to the due date. Any late submission will incur the 20% perday penalty. It is strongly suggested that you submit the assignment well before the deadline, in casethere are some unexpected complications on the day (e.g. interruptions to your home internetconnection).ExtensionsAll requests for extensions must be sent to Mark Creado ([email protected]). Requests mustfollow the faculty guidelines, include the required forms and be submitted as soon as possible. Inaddition, when emailing for an extension, please remember to include all code completed until thattime. This assignment cannot be completed in a few days and requires students to apply what we learneach week as we move closer to the submission date.PlagiarismCheating and plagiarism are viewed as serious offences. In cases where cheating has been confirmed,students have been severely penalised, with penalties ranging from losing all marks for an assignment,to facing disciplinary action at the Faculty level. Monash has several policies in relation to theseoffences and it is your responsibility to acquaint yourself with these.Plagiarism (http://www.policy.monash.edu/policy-bank/academic/education/conduct/plagiarismpolicy.html)  

admin

Author admin

More posts by admin