Connect4
In this second piece of coursework you will need to analyse, design and extend a second program. This program should allow a human to play the game Connect4 against a computer.
The game is described here. Please ignore the “Rule variations” listed’ on Wikipedia – you should only implement the standard version of the game.
The game Connect4 is a game that can be played between a human and a computer player, on a 6×7 grid. The goal is to connect 4 tokens either diagonally, horizontally or vertically.
You have a program to work with. https://repl.it/@bathuniversity/Coursework2
Unfortunately, the code:
• Doesn’t compile or run.
• Is poorly designed (e.g. is largely made up of a huge main function without comments). With everything we’ve learned about OO, we will need to redesign the code to adhere to these principles.
• Needs extension to meet an updated specification (more players, more tokens!).
• Complete all 5 requirements listed below. You have 2 weeks to complete this coursework, so I suggest:
• This week you should complete Requirements 1 and 2, and start work on Requirement 3. Hint: Take you time on Requirement 2 and 3, if you really consider the OO design in your report, it should be easier to tackle the code. Requirement 4 and 5 become rather trivial modifications to the code!
• Next week you should complete work on Requirement 3, 4 and 5.
• The faulty Connect4 program is available in the repl.it window above. You can also download it as a .java file here.
• Your submissions should be a zip file that can be extracted to a folder with the name PrinciplesOfProgramming-Connect4. The directory should contain, as per the 5 requirements:
• A bug/omission list
• A report on restructuring our code according to OO principles
• A sub-directory containing the java files required to run your version of Connect4
• A (shorter) report on how you’d extend your game to 3-player ConnectN
• A sub-folder containing the java files required to run your version of 3-player ConnectN
• Before you upload your solution, make sure that the zip file contains all necessary files and sub-folders.
Requirement 1
Up to 20 marks
Provide a bug and omission list (1-2 pages of single-spaced, 10 point font) explaining why the version of the code provided doesn’t work (in the case of bugs)and/or doesn’t provide the functionality needed to play Connect4.
Each bug/omission in the list should be described in the following format:
• Class : Line(s) : Bug/Omission : Type if Bug (syntax/run time/logic)
• Solution.
e.g.:
• Board.java : Line 7 : char entered where int expected : syntax error
• Solution: Guard against non integer inputs.
It is likely an omission will not have a line number, e.g. does the game actually do what it claims to?
Requirement 2
Up to 20 marks
Write a report (2-3 pages of single-spaced, 10 point font) describing the ways in which our code could be restructured to better reflect the fundamental OO concepts of modularisation and encapsulation.
Include a discussion in that report of the extent to which you think that inheritance, abstract classes and interfaces might be used to improve our code. You may argue either for or against their inclusion.
Requirement 3
Up to 20 marks
Submit a revised version of our code which compiles and runs to provide a working version of the game Connect4. More specifically, provide an altered but uncompiled reworking of our code that allows 1 human player to play a complete game of Connect4 against 1 computer.
Your code will ideally follow the object oriented principles you described in Requirement 2. You must not rely on external libraries, please complete this assignment with the use of standard libraries only please. If you are using an IDE (not repl.it) please do not submit the entire directory structure of your project: all .java files should be in the same folder.
To get started on this assignment, you may wish (but are not obliged) to start by commenting out large parts of our code and altering our printBoard() method. This approach has the advantage of giving you a relatively manageable starting point in the debugging process.
You may also wish to tackle our placeCounter() method next.
Requirement 4
Up to 20 marks.
Write a further “report” to describe how the code could be altered to allow a human player to play a game of ConnectN against two computer players (3 players in total). Be specific, what in your code will change?
ConnectN is a game identical to Connect4 except that:
• The winning condition is that N counters of the same colour are placed in a line and
• One human player competes against two computer players.
N will be passed to the code as a command line argument and 2 < N < 7. If you cannot get command line arguments to work, start out by simply setting a variable N in your code to test out your solution.
You may adopt an approach that keeps/replaces as much of our code as you find appropriate. You may include up to half a page of high-level pseudo code in this part of your coursework.
Note, we say "report" because it is possible this may be no more than a few paragraphs, depending on how you designed your original Connect4 game.
Requirement 5
Up to 20 marks.
Submit an updated and extended version of your code which compiles and runs to provide a working version of the game 3-handed connectN (as described in Requirement 4). This game needs to work for 1 human player playing against 2 computer players, where N is more than 2 and less than 7.
Grading
• This assignment is worth 40% of your total grade.
• Marks are available in the following areas:
• Bug/Omission list: Max 20 marks.
• Report on restructuring our code to reflect OO concepts: Max 20 marks.
• Revised (i.e. working) Connect4 code: Max 20 marks.
• 10 marks for functionality and
• 10 marks for improved reflection of OO concepts.
• Report on extending our code to support ConnectN: Max 20 marks.
• Revised and extended ConnectN code: Max 20 marks i.e.
• 10 marks for functionality and
• 10 marks for improved reflection of OO concepts.
Total: Max 100 marks.
For the code that you submit, marks will be awarded for functionality, code quality, appropriate use of object oriented programming principles and commenting.