Introduction to Systems Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Assignment 2 Accompanying this assignment you will find an archive file gt2048.zip. The zip contains a directory gt2048,with a BlueJ Java project for the GT 2048 application.2048 is a puzzle game implemented originally as a web-based video game in 2014. The game has a 4 × 4 gridsliding board with numbered tiles, where tiles get combined according to user moves. The goal of the game isto combine tiles so as to reach a board configuration containing a tile with value 2048Initially, the board starts with only two tiles, placed in random positions, and containing each either 2 or 4. Theuser interacts with the game by moving in four possible directions (up, down, left or right). The user movementcauses the tiles to move as far as possible in the chosen direction, until reaching another tile, or the edge of theboard. When two tiles of the same number collide while moving, they will merge into a tile whose value is thesum of the two colliding tiles. After each movement, and only if the board has changed its configuration as aconsequence of the move, a new tile is randomly located at a free slot in the board, with either 2 or 4 (randomlychosen). When a board with no free slots where to placethe spawning tile is reached, the game ends. There aresome subtleties in the game playing too, such as a “merged tile” not being able to be combined with anothertile in the same movement, as well as in the order in which the merging occurs (tiles closer to the edge of theboard limiting the movement merge first).Project GT2048 is a text-based implementation of the 2048 game. It consists of four classes:
- GT2048Cell: it is the simplest of the classes. It models a cell of the 2048 board, with all its possiblestates: “empty”, or containing a numeric value. The value of a non-empty cell must be a power of two,due to the rules of the game. This class is accompanied by a test suite, i.e., a class containing unit testsfor some of the methods of the GT2048Cell class.
- GT2048Board: it models the board through a bi-dimensional array of cells, each cell being represented bya GT2048Cell object. It contains methods to initialize the game, react to user movements, etc.
- GT2048InputReader: it implements the reading of input commands.
- GT2048: the main class of the game. Its constructor creates the input reader object and game board, andenables initiating the game by calling method startGame().Your assignment consists of various tasks:
- Study the behavior of the game by interacting with it in https://play2048.co.
- Study the provided implementation (including the provided tests), so as to understand how the solutionis organized and partially implemented.
- Implement all the methods with missing implementations in class GT2048Board. These include all themethods that implement movements, as well as the ones that decide whether a given movement is possible.
- Create a test class for testing GT2048Board. Design and implement in the test class sufficient unit teststo thoroughly check the correct behavior of at least one movement method. Try to cover with your testsall the statements in the selected method (i.e., every statement in the method should be executed by at
east one test).If you find errors (bugs) in 代写Introduction to Systems Programming . the existing code (not your implementation, but the existing code), you mustfix them and provide unit tests that fail for the original buggy code, and pass with your fix. Your unittests should describe, in the comment, what the found bug was, and how was solved.6. The previous tasks should lead you to a fully functional implementation of the game. Identify at leastone design problem in the implementation (e.g., tight coupling, low cohesion, duplicate code). Textuallydescribe the problem, and a potential solution, at the bottom of the README file in the project.
- Make a copy of your solution to all tasks, and bundle it in a zip file, as version 1.zip, before continuingwith the following tasks.
- Extend your implementation with behavior that implements user login, and scores. Your implementationmust not modify neither GT2048Cell nor GT2048Board (i.e., these classes should be exactly the same thatyou bundled into version 1.zip. Your extension must implement the following behavior:
- Ask the user to provide its username (no password) before starting the game.
- Maintain, for each user, its corresponding highest score. The score of a finished game play is the sumof all the cells in the board; it is computed only for finished games (either reaching 2048 or not). Foreach user, we only maintain his/her highest score. When a user plays the game for the first time, itscore is created with zero at the start of the game; it is updated when the player finishes the game.
- The application must allow players to play subsequent games without exiting, possibly changing thuser for each game play. When no game is being played, the application must allow one to print outhe scores of all players.To implement the above score related functionality, you may modify existing classes (except GT2048Cell
and GT2048Board), and add new classes. Your solution must not implement any persistence mechanism,i.e., when the application is terminated, all scores are lost.
Your assignment is to fulfill all the above tasks. You may decide to add auxiliary methods as private, or
implement the required functionalities within the provided method bodies. For the first part (until “version 1”of your game), you are not allowed to change the APIs of the classes, i.e., not change method names, numberof parameters or their types.You must submit the solution through moodle, as a zip archive containing the whole final project, as well asthe version 1 project, either in a separate zip, or as a zip inside the main submission archive. This assignmenmust be solved individually. The correctness of your solution is important, as so is the quality of the code(clarity, readability, structure, etc.). The quality of your design for the score functionality, including how theimplementation is organized and how you decide to representthe necessary information (what data structuresto use), will be important.
标签:tiles,zip,Introduction,user,Programming,game,Systems,your,board From: https://www.cnblogs.com/CSE2425/p/18596860