Question: In this assignment, you'll make a simple game where a duck, a mouse, and a turtle are on some island with 2 cats. Each




In this assignment, you'll make a simple game where a duck, a mouse, and a turtle are on some island with 2 cats. Each animal will be given a set of directions to move around the board and you need to output the result of its movement as one of the following: - Eaten by the cat. - Escape through the bridge. Drowns outside the island. - Stuck inside the board. Requirements: Class Animal (Abstract Class) Attributes: protected variables: rowPosition (integer) columnPosition (integer) public variables boardSize (static integer) Board (static 2D dynamic array) Methods (all public): pure virtual functions .getType() receives nothing and returns a string. move(char c) receives a character and returns a bool. getRow() receives nothing and returns an int. getColumn() receives nothing and returns an int. Static functions getBoardCell(int r, int c) returns the char value inside the cell at row r and column c on the board array. .setBoard (int c1r, int c1c, int c2r, int c2c) o initializes the array to be boardSize x boardSize. o initializes the whole board array to the value '-' except for three cells: 2 cell will contain the value 'C' representing the 2 cats at row c1r and column c1c, and at row c2c and column c2c respectively. 1 cell will contain the value 'B' representing the bridge to the exit, which is always at the last column and the middle row. setBoard(int cir, int c1c, int c2r, int c2c) o initializes the array to be boardSize x boardSize. o initializes the whole board array to the value '-' except for three cells: 2 cell will contain the value 'C' representing the 2 cats at row c1r and column c1c, and at row c2c and column c2c respectively. 1 cell will contain the value 'B' representing the bridge to the exit, which is always at the last column and the middle row. Class Duck (Inherits from Animal) Class Mouse (Inherits from Animal) Class Turtle (Inherits from Animal) Methods (all are public): default constructor sets the rowPosition and columnPosition to 0. constructor takes two parameters to set rowPosition and column Position. getType() Implementation returns "duck", "mouse", or "turtle". move(char c) Implementation updates rowPosition or columnPosition based on the character c which can have any of the values (U, D, L, and R). The function returns false if the movement in the specified direction will lead to going out of the bounds of the board, i.e. array, otherwise, it returns true. getRow() Implementation getColumn() Implementation Main File 1. Initialize the boardSize static attribute to 9. 2. Create three objects, one of type Duck, one of type Mouse, and one of type Turtle, and give each object its initial position using its constructor. 3. Create an array called of pointers to Animal that stores the addresses of the previous objects. 4. Call setBoard and give it any numbers as the positions of the two cats. 5. Iterate through the array to take in each iteration a string from the user representing the characters an object will move, for example "UDLD". You should iterate through this string to know what will happen to each object. It's guaranteed that the string would always be 4 characters long. 6. Based on the result of the movement, the program prints the type of the object followed by on the messages below: "escaped" If the object encounters the bridge. "got eaten" If the object encounters any cat. "drowned" If the object moved out of the board. "Starved" otherwise, i.e. If the object is still in the board. Sample Run: Assume that the positions of the cats are (3, 5) and (4, 1). Assume that the initial position of the Duck is (1, 1), and that of the Mouse is (2, 2), and that of the Turtle is (5, 5). If the user enters: DDDD RRUL URRR If the user enters: UURR RRRD LDRL Output: The duck got eaten. The mouse is stuck. The turtle escaped. Output: The duck drowned. The mouse got eaten. The turtle is stuck.
Step by Step Solution
There are 3 Steps involved in it
include include include class Animal protected int rowPosition int columnPosition public static int boardSize static stdvector Board virtual stdstring getType 0 virtual bool movechar c 0 int getRow re... View full answer
Get step-by-step solutions from verified subject matter experts
