Starting from:
$30

$24

Homework # 4 Solution

In this homework, you will write your game of reversi program in C++ using object oriented techniques.




First, write a class named Cell to represent a reversi cell. The class Cell will hold the X and Y positions of the cell ( a char and an int values). This class will also include all necessary setters/getters, costructors etc. Remember a cell can be empty, user or computer




Next, write a class named Reversi to represent and play the game. The class Reversi will hold a vector of vector of Cell objects to represent the living cells. In other words, this class will have vector< vector<Cell gameCells; in its private section.




The class Reversi will also have the following features and functions




There is no limit for the board. Your game will resize according to the parameter for the constructor.
There should be at least 3 contructors.



The class will have functions to read and write from files. You will decide on the file format.



The class will have functions to return the current width and height of the board



The class will have a function that displays the current board on the screen



The class will have two functions named play that plays the game for a single time step. First function does not take a paremeter and it plays the computer. The second function takes a cell position and it plays the user.



The class should have a function that returns if the game ended.



The class should have a function named playGame. This function plays the game by asking the user the board size first then asks the user to play and the computer plays, etc.



The class will have a static function that returns the number of living cells in all the games. Be careful here because there could be more than one game active at the same time.
The class will have a function that takes another object Reversi as parameter and compares the reversi games. It returns true is the first game is better for the user, otherwise it returns false.



Any other functions (public or private) needed.



Write your main function to test both classes. Make at least 5 objects of class Reversi and play the games at the same time.




You will use all the object oriented techniques that we learned in the class including const, static, inline keywords.




Notes:

Do not use any C++ features that we did not learn during the lectures.

More products