Java / Object Oriented Total 50 marks
This question requires you to provide an object-oriented design for a system to allow a game to be played. You should not try to produce full Java code for the system and will instead need to provide Java code for specific elements of the system. Consider the requirements on pages 3 to 5 and answer the following questions. Page 3 provides an overview of the game that should be supported, page 4 explains some details of requirements to support and page 5 gives you details of a supplied class and some hints.
a) Describe your design [18 marks]
- Provide a class diagram for your system. Include all of your own classes, as well as the TextInputOutput class in your class diagram. Include all relationships, attributes,and operations for the classes shown.
- Explain what each of your classes will do, the relationships that it has with other classes, and why, and outline what each method of each of your classes will do. You do not need to provide code for any of the methods (but see Q1c), just an outline to a similar level of detail given for the methods of the class TextInputOutput earlier.
- Explain briefly how your program works – what objects are created, when, and which methods call which other methods to achieve the aims of your program. You may provide Java code samples if it will help your explanation, or may refer to any code from Q1c later, as long as you explain it here.
b) Describe your use of common design patterns [16 marks]
- Explain briefly where and how you have used any common design patterns, explaining what each pattern is, why it is used, and how you would implement the pattern in your design. You should include any code samples you feel will clarify your answer.
c) Provide code and explanation for parts of your program [16 marks]
Assuming that the rules are implemented as described above (the basic rules), provide Java code and a brief explanation of what it is doing/how it works for the following parts of your design/program:
- Your main() function.
- Your own sub-class of TextInputOutput, and lineRead() method.
- Your validateMove() method.
You should assume that any other methods and classes described in your answer to Q1a exist and work appropriately, so that you can call them from your code here without having to provide implementations for them yourself.
Description of the game to support
Assume that someone is designing a new board game and wants a computer version of the game to try it out.
- The game is played on an 8×8 grid. The columns are labelled with letters and the rows with numbers. Any square is empty, contains a red piece, or contains a blue piece.
- There are two players, one player (the blue player) has 16 identical blue pieces, which start on rows 1 and 2, and the other player (the red player) has 16 identical red pieces,which start on rows 7 and 8. Figure 1 shows the initial position, where B denotes a blue piece and R a red piece.
- Any square can be specified by its column letter and row number. E.g. Square A2 is the square in column A, row 2; square G4 is the square in column G, row 4; the top left corner is A1 and the bottom right corner is H8.
- Any move can be specified as a five-character string, specifying the column and row to move from, a dash/minus ( ‘-‘ ) then the column and row to move to. E.g. ”A2-A3” means move the piece in position A2 from A2 to position A3. “A3-B2” means move the move the piece from position A3 to position B2.
- There are specific rules about how a piece can move and these can be changed for testing. The basic rules to get you started are considered below, but it should be assumed that these ‘basic rules’ could be changed by the designer.
- For the basic rules, players must take it in turns to move, starting with the player playing blue. The red player wins if they move a piece to any square on row 1, and the blue player wins if they move a piece to any square on row 8. Either player wins if the other player is not able to make a move when it is their turn.
- For the basic rules, in their turn a player can move a piece to any empty adjacent square (horizonally, vertically or diagonally). Making a move could result in capturing one or more of the opponent’s pieces, but for simplicity, the rules for capturing do not matter for this exam and you will not need to write the code to check for this or to implement it. You should provide functionality to allow pieces to be moved around the board, and to be removed from the board if they are captured.
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: email@example.com 微信:itcsdx