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,文本读取

更多可加微信讨论

微信号:tiamo-0620

pdf

FIT9131 Semester 2 2019 Assignment 2
Page 1 of 8

With
Arraylists

Introduction
This document specifies the programming component of Assignment 2. This component is due by
11pm 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 of
any part of your code which you have not written yourself. Please note the section on plagiarism in
this document.
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.
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, 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
    FIT9131 Semester 2 2019 Assignment 2
    Page 2 of 8
    256 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 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:
  4. The game starts by registering a player to play the game.
  5. The game then provides a random multiple to the player which is stored in the game total
    from the available multiples…
  6. The Arraylist buffer (b1) is empty.
  7. 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 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 4 above.
    o 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.
  8. 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 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.
    Game
    Total
    (t)
    ArrayList
    Buffer 1
    (b1)
    FIT9131 Semester 2 2019 Assignment 2
    Page 3 of 8
    256 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 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 the
    first 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 (for illustration only):
    The game sequence is as follows:
  9. The game starts by registering a player to play the game.
  10. 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.
  11. 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).
  12. The game then provides a random multiple to the player which is stored in the game total.
  13. Both the Arraylist buffers (b1 and b2) are empty.
  14. 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 arraylist
    buffer (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 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 4 above to
    allow the player to continue.
    o Split Left ()
     This allows the player to add the game total (t) number to the left arraylist
    buffer (b1)
    Game
    Total
    (t)
    Arraylist
    Buffer (b1)
    Arraylist
    Buffer (b2)
    FIT9131 Semester 2 2019 Assignment 2
    Page 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 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 4 above to
    allow the player to continue.
  15. 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 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.
    Hints and Suggestions
    Your 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 to
    look up the Integer.parseInt() method which belongs to the Integer class. This can be used along
    with exception handling to ensure your program doesn’t crash.
    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.
    FIT9131 Semester 2 2019 Assignment 2
    Page 5 of 8
    Gameplay Example (HD Level Only)
    The following shows a single game play using the multiples 2, 4, and 8. And the winning game total
    is going to be 16.
    更多可添加微信
    在这里插入图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值