Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part A: Convert the Tile Module to a Class (35% = 24% test program + 11% code] In Part A, you will convert the l'ile

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Part A: Convert the Tile Module to a Class (35% = 24% test program + 11% code] In Part A, you will convert the l'ile type to an encapsulated class. You will also add a class invariant that requires the tile genus to be strictly less than GENUS_COUNT. By the end of Part A, your Tile class will have the following public member functions: Tile (); Tile (unsigned int genusi, unsigned int species1); bool isOwner () const; unsigned int getAffectedPlayer ( unsigned int whose_turn) const; unsigned int getGenus () const: unsigned int getSpecies () const; void setOwner (unsigned int owner1); void activate (unsigned int whose_turn) const; void print ( const; You will also have the following private member functions: void printownerchar () const; void printGenuschar (const; void printSpeciesChar () const; bool isInvariantTrue () const; Perform the following steps: 1. Convert the Tile record to a class. The fields should become orivate member variables. 2. Convert the Tile-associated functions to member functions in the interface (ie, ..) and implementation (i.e.,.cpp) files. The le Print Choc functions should be private and the others be pubic. The tileczeate function should become the non-default constructor. Remove the word Lil from the function names and change the new first letter to lowercase. In the implementation file, add Tile:: before every function name. Reminder: A in a name means anything. 5o tilePrint Char refers to three functions. Perform the following steps: 1. Convert the Tile record to a class. The fields should become private member variables, 2. Convert the le-associated functions to member functions in the interface fie...h) and implementation i.e.,.cpp) files. The ti le PritilCher functions should be private and the others should be pubic. The tileCreate function should become the non-default constructor. Remove the word tile from the function names and change the new first letter to lowercase. In the implementation file, add Tile:: before every function name. Reminder: A in a name means "anything". So tileprint Choc refers to three functions. Reminder: If a member function calls another member function, you will have to update the name in the call as well. 3. Remove the Tile parameter from all the functions. Inside the functions, update the member variables to not use dot notation. For example, tile.gcrus should become plain genus 4. Add a default constructor that sets the owner to NO CANER, the genus to GENUS MONEY, and the species to 1. Remember to add the function prototype. Note: If we don't declare a defauit constructor, the compiler will not allow us to declare an array of Tiles (Because it has to call the default constructor for each element when an array is created.) So we need the default constructor or the board won't work, 5. Add a precondition to the non-default constructor that requires the cenusi parameter to be strictly less than CENUS COUNT, Use an asset to enforce the precondition, Reminder: Every constructor must initialize every member variable. In this case, your constructor must initialize the genus, the species, and the owner 6. Add a private const member function named is invarian true to check the class invariant. It should return true if the tile genus is strictly less than GENUS_COUNT and faloc if it is the same or greater 7. Check the class invariant at the end of every non-const public member function. For the le class, this is both constructors and clowner. At the end of each of these functions, use an assert to make sure that is InvariantTrue returns true assert is Invariant True () The purpose of this is to ensure that these functions do not leave the Tile in an invalid state. The consl functions cannot change the tile state, so we don't need to check the invariant there. Note: Don't check the invariant in private functions. It will be checked in the functions that call them 8. Check the class invariant at the start of every public member function except the constructors. Use an assert to make sure that is invariant ILue returns Lue. The purpose of this is to ensure that the Tle in a valid state when the function is called. Reminder: Don't check the invariant in private functions. 2. Test your le module using the ret 9. Test your si le module using the Testrile3.cop program provided. As always, you will need TestHelper, n and TestHelper.cpo. Part B: The Board Class [25% = 15% test program + 10% documentation] In Part B. you will convert your board module to an encapsulated class. The Roard class will not have a class invariant. By the end of Part B, your board class will have the following public member functions: Board (): void print () const; const Tile getAt (const Cellide cell id) const; void setAt (const Cellid& cell_id, const Tilee value, unsigned int owner): You will also have the following private member functions: void printColumnNameRow () const; void printBorder Row () const; void printEmpty Row () const; void printDataRow (int row) const; Perform the following steps: 1. Declare a Board class in Board.h. It should have a 2D array of Tiles as a private member variable. Remove the Board typedef 2. Convert the existing function prototypes to member functions or copy in the ones shown above. Update the functions in the Board.cpp implementation file to match the new prototypes. 3. Convert the boardinit function into a default constructor. When assigning values to the board array, use the non-default r le constructor. The syntax is: ar suy name[11- Tile (put value for parameters here); 4. Change the getAt and setAt functions to take a conal reference to a Cellid as a parameter instead of a row and a column 5. Add a precondition to the getAt and setAt functions, enforced by an asserl. It should require that the cell is on the board. Hint: You have a function to check that a cellis on the board. 6. Add a parameter to the set Al function for the new tile's owner. The function should set the new file on the houdt ter Au a parameter to the sot function for the new file's owner. The function should set the new tile on the board to have that owner. Add a precondition that the tile parameter does not already have an owner Hint: Use a function from the Tilc class to change the owner - Hint: Use the 150wner function from the Tlle class to check whether a lile has an owner 7. Test your Board class using the sect Board3.can program provided 8. Update your main function to use the new island Roard classes. It should run as before. Hint: You will begin by declaring a variable of the Board type. Suppose it is named vor (but you should use a better name!). When you declare a variable such as var and you do not put parentheses after the name of the variable, C++ will automatically call the default constructor. You do not need to explicitly call the default constructor. You should delete the call to the bourdinit function Buard var: Hint: Suppose you used to call a function named boardeur with a parameter of type Board as the first parameter. Now instead you want to call a function named fund for an instance of the Board class, such as var. In this case, you first give the name of the variable, then a dot, then the name of the function, and then any parameters in parentheses. Suppose the old code was boardFunc(var, values for other parameters); then the new code should be var.fune values for other paranclers) 9. Write interface specifications for the four phle functions in the Buard class. Use the format described in class and in Section 4a of the anline notes. You do not have to write interface specifications for the private functions. - Reminder: Interface specifications are written for other programmers who want to use your module. Part C: The AvailableTiles Class [40% = 26% test program + 4% code] In Part C. you will create and document a class named Avallahietiles. The class will keep track of the five tiles that are available for the players to buy and the cast for each. At the start, five tiles will be chosen randomly. Whenever a tile is removed, the higher numbered tiles will be moved down and a random new tile will be added at the end. For example, suppose we refer to the available tiles as, J. K, L, M. Also suppose that tile k was removed and a new tile (referred to as N) was picked randomly to be added. Then the revised list of available tiles would be t. J. IM, N. When the tiles are moved, their costs move with them. Note: A tile is actually a three-part object with owner, genus, and species member variables--we are referring to them by single letters for convenience here. Note: When you remove the tile from the available tiles list, a new tile will be placed in the last nosition of the www.cs.uregina.ca/anima/115/Terms/202710/Assignments/Assignment3/Assignment3.htm Part C: The AvailableTiles Class [40% = 26% test program + 4% code] In Part C, you will create and document a class named Availablefiles. The class will keep track of the five tiles that are available for the players to buy and the cost for each. At the start, five tiles will be chosen randomly. Whenever a tile is removed, the higher numbered tiles will be moved down and a random new tile will be added at the end. For example, suppose we refer to the available tiles as I, J, K, L, M. Also suppose that tile i was removed and a new tile (referred to as N) was picked randomly to be added. Then the revised list of available tiles would be T., L, M, N. When the tiles are moved, their costs move with them. Note: A tile is actually a three-part object with owner, genus, and species ember variables-we are referring to them by single letters for convenience here. Note: When you remove the tile from the available tiles list, a new tile will be placed in the last position of the list. . By the end of Part C, your Availableriles class will have the following pubize member functions. AvailableTiles () : void print () const; int getCost (unsigned int index) const; const Tile getTile (unsigned int index) const; void replaceAt (unsigned int index); You will also have the following private member function void setRandomTile (unsigned int index); Perform the following steps: 1. In AvailableTites.n, declare an unsigned integer constant named AVAILABLE TTLL_COUNT for the number of available tiles. It should have value 5. Since it is constant, the number of available tiles never changes 2. Create the Available: les class. It should have member variables that store the available tiles and tile costs. One way to do this is to have two arrays of the same length with the first array of the le type and the second array of the int type. 3. Copy in the function prototypes. 4: In AvailableTiles.cpp, write the implementation for the set Randomtile function. You should construct a tile and copy it (with an assignment operator =) into the specified position in the available tiles list. You should also set the corresponding cost. The owner member variable of the tile will be set to NO CYNER by the title noints tiles. Choose a random fm the preconditions with asserts. 7. Write the implementation for the replaceat function. It should move the tiles that have higher indexes one spot down the array and call a function to set the last tile position in the list to a random bile. Add an assert enforced precondition that requires the index parameter to be strictly less than the number of tiles. Reminder: Also move the costs when you move the tiles. Hint: You can assign objects, such as Tiles, with the assignment statement, just like any other variable. Sometimes this is referred to as copying the objects. For example: MyClass c1; Myclass c2; cl - 2; // this is legal Example: Suppose the user selects position 2. Then copy the tile from position 3 into position 2 (using an assignment statement =) and copy the cost from position 3 to position 2. Then copy the tile from position 4 to position 3 and copy the cost from position 4 to position 3. Then set position 4 to be a random tile. Example: Suppose the user selects position 0. Then copy the tile from position 1 into position (also cost), then copy the tile from position 2 to position 1 (also cost), then copy the tile from position 3 to position 2 (also cost), then copy the tile from position 4 to position 3 (also cost). Then set position 4 to be a random tile. Example: Suppose the user selects position 4. None of the tiles need to be copied. Set position to be a random tile. Hint: You should be able to write a lor loop that does any of the above examples. 8. Test your Availabler le module using the Teal Availablerts es3.car program provided. Part D: improve the main Function (10% output] n Part D, you will use your Available les class in the main function. Instead of simply placing tiles, players will buy them from a list of available tiles. If the player doesn't have enough money, he/she will not be able to buy the tile. 1. Add an AvailableTiles variable to your main function Print it out after printing the board but before printing whose turn it is. Use one of your functions from the Avaliabletles class to print it. Hint: Since the board is a variable of a class type, you will print the board by writing the variable name, then a dot, then the name of the print function, and then parentheses containing any parameters -2 After the player chooses a valid cell to place atile in, the player should program should ask the player to choose a tile to place buy so that it can be placed there. To do so, the program should first ask which tile by index the player wants to put there buy and read in the player's answer. If the index is invalid, print a failure message. Otherwise, if the player does not have enough money to pay the cost for that tile, print a failure message. Otherwise, add the tile to the game board, reduce the player's money, remove the tile from the available tiles list, and print a success message. parameters After the player chooses a valid cell to place a tile in the player should program should ask the player to choose a tile to plaee-buy so that it can be placed there. To do so, the program should first ask which tile (by index) the player wants to put there buy and read in the player's answer. If the index is invalid, print a failure message. Otherwise, if the player does not have enough money to pay the cost for that tile, print a failure message. Otherwise, add the tile to the game board, reduce the player's money, remove the tile from the available tiles list, and print a success message. Hint: To add a tile to the game board, first retrieve it from the available tiles list by using the gettle function and then store it in the game board by using the set. At function. Remember to use dot notation to call these functions. . . Note: When you remove the tile from the available tiles list using the replaceat function, a new tile will be placed in the last position of the list. Note: You may assume that the player enters an integer for the tile index. In other words, you do not have to handle all types of incorrect input. If the player does not succeed in placing a tile, remove the first tile (the one in position C) from the available tiles list Hint: Create a bool variable and set it before asking the player for a cell. Then change the value if the player successfully adds a tile. If the variable still has its original value after all the checks, then the player failed to place a tile. Formatting (-10%) 1. Neatly indent your program using a consistent indentation scheme. 2. Put spaces around your arithmetic operators: - x + 3; 3. Use symbolic constants, such as BOARD SIZE, when appropriate. 4. Include a comment at the top of Main.cpp that states your name and student number. 5. Format your program so that it is easily readable. Things that make a program hard to read include: Very many blank lines. If more than half your lines are blank, you probably have too many. The correct use of blank lies is to separate logically distinct sections of your program: Multiple commands on the same line. In general, don't do this. You can if it makes the program clearer than if the same commands were on separate lines. Uninformative variable names. For a local variable that is only used for a few lines, it doesn't really matter. But a variable that is used over a larger area (including all global variables and field names) should have a name that documents its purpose. Similarly, parameters should have self documenting names because the function will be called elsewhere in the program, Submission Submit a complete copy of your source code. You should have the following files with exactly these names: 1. AvailableTiles.h - 5. Format your program so that it is easily readable. Things that make a program hard to read include: Very many blank lines. If more than half your lines are blank, you probably have too many. The correct use of blank lies is to separate logically distinct sections of your program. Multiple commands on the same line. In general, don't do this. You can if it makes the program clearer than if the same commands were on separate lines. Uninformative variable names. For a local variable that is only used for a few lines, it doesn't really matter. But a variable that is used over a larger area (including all global variables and field names) should have a name that documents its purpose. Similarly, parameters should have self-documenting names because the function will be called elsewhere in the program. Submission Submit a complete copy of your source code. You should have the following files with exactly these names: 1. AvailableTiles.h 2 AvailableTiles.cpp 3. BoardSiznih 4. BoardSize.cpp 5. Board.h 6. Board.cpp 7. Celltd. 8. Celltd.cpp 9. Dice.h 10. Dice.cpp 11. Main.cpp 12. Tile.h 13. Tile.cpp Note: A Visual Studio . xin file does NOT contain the source code, it is just a text file. You do not need to submit it. Make sure you submit the.cpp files and files. Note: You do not need to submit the test programs or the Player 1 and Playe-.cpp files. The marker has those already If possible, convert all your files to a single archive (.zip file) before handing them in Do NOT submit a compiled version Do NOT submit intermediate files, such as o Debug folder e Release folder ipch folder 0.o files anch, .sdf, or .db files Do NOT submit a screenshot . Part A: Convert the Tile Module to a Class (35% = 24% test program + 11% code] In Part A, you will convert the l'ile type to an encapsulated class. You will also add a class invariant that requires the tile genus to be strictly less than GENUS_COUNT. By the end of Part A, your Tile class will have the following public member functions: Tile (); Tile (unsigned int genusi, unsigned int species1); bool isOwner () const; unsigned int getAffectedPlayer ( unsigned int whose_turn) const; unsigned int getGenus () const: unsigned int getSpecies () const; void setOwner (unsigned int owner1); void activate (unsigned int whose_turn) const; void print ( const; You will also have the following private member functions: void printownerchar () const; void printGenuschar (const; void printSpeciesChar () const; bool isInvariantTrue () const; Perform the following steps: 1. Convert the Tile record to a class. The fields should become orivate member variables. 2. Convert the Tile-associated functions to member functions in the interface (ie, ..) and implementation (i.e.,.cpp) files. The le Print Choc functions should be private and the others be pubic. The tileczeate function should become the non-default constructor. Remove the word Lil from the function names and change the new first letter to lowercase. In the implementation file, add Tile:: before every function name. Reminder: A in a name means anything. 5o tilePrint Char refers to three functions. Perform the following steps: 1. Convert the Tile record to a class. The fields should become private member variables, 2. Convert the le-associated functions to member functions in the interface fie...h) and implementation i.e.,.cpp) files. The ti le PritilCher functions should be private and the others should be pubic. The tileCreate function should become the non-default constructor. Remove the word tile from the function names and change the new first letter to lowercase. In the implementation file, add Tile:: before every function name. Reminder: A in a name means "anything". So tileprint Choc refers to three functions. Reminder: If a member function calls another member function, you will have to update the name in the call as well. 3. Remove the Tile parameter from all the functions. Inside the functions, update the member variables to not use dot notation. For example, tile.gcrus should become plain genus 4. Add a default constructor that sets the owner to NO CANER, the genus to GENUS MONEY, and the species to 1. Remember to add the function prototype. Note: If we don't declare a defauit constructor, the compiler will not allow us to declare an array of Tiles (Because it has to call the default constructor for each element when an array is created.) So we need the default constructor or the board won't work, 5. Add a precondition to the non-default constructor that requires the cenusi parameter to be strictly less than CENUS COUNT, Use an asset to enforce the precondition, Reminder: Every constructor must initialize every member variable. In this case, your constructor must initialize the genus, the species, and the owner 6. Add a private const member function named is invarian true to check the class invariant. It should return true if the tile genus is strictly less than GENUS_COUNT and faloc if it is the same or greater 7. Check the class invariant at the end of every non-const public member function. For the le class, this is both constructors and clowner. At the end of each of these functions, use an assert to make sure that is InvariantTrue returns true assert is Invariant True () The purpose of this is to ensure that these functions do not leave the Tile in an invalid state. The consl functions cannot change the tile state, so we don't need to check the invariant there. Note: Don't check the invariant in private functions. It will be checked in the functions that call them 8. Check the class invariant at the start of every public member function except the constructors. Use an assert to make sure that is invariant ILue returns Lue. The purpose of this is to ensure that the Tle in a valid state when the function is called. Reminder: Don't check the invariant in private functions. 2. Test your le module using the ret 9. Test your si le module using the Testrile3.cop program provided. As always, you will need TestHelper, n and TestHelper.cpo. Part B: The Board Class [25% = 15% test program + 10% documentation] In Part B. you will convert your board module to an encapsulated class. The Roard class will not have a class invariant. By the end of Part B, your board class will have the following public member functions: Board (): void print () const; const Tile getAt (const Cellide cell id) const; void setAt (const Cellid& cell_id, const Tilee value, unsigned int owner): You will also have the following private member functions: void printColumnNameRow () const; void printBorder Row () const; void printEmpty Row () const; void printDataRow (int row) const; Perform the following steps: 1. Declare a Board class in Board.h. It should have a 2D array of Tiles as a private member variable. Remove the Board typedef 2. Convert the existing function prototypes to member functions or copy in the ones shown above. Update the functions in the Board.cpp implementation file to match the new prototypes. 3. Convert the boardinit function into a default constructor. When assigning values to the board array, use the non-default r le constructor. The syntax is: ar suy name[11- Tile (put value for parameters here); 4. Change the getAt and setAt functions to take a conal reference to a Cellid as a parameter instead of a row and a column 5. Add a precondition to the getAt and setAt functions, enforced by an asserl. It should require that the cell is on the board. Hint: You have a function to check that a cellis on the board. 6. Add a parameter to the set Al function for the new tile's owner. The function should set the new file on the houdt ter Au a parameter to the sot function for the new file's owner. The function should set the new tile on the board to have that owner. Add a precondition that the tile parameter does not already have an owner Hint: Use a function from the Tilc class to change the owner - Hint: Use the 150wner function from the Tlle class to check whether a lile has an owner 7. Test your Board class using the sect Board3.can program provided 8. Update your main function to use the new island Roard classes. It should run as before. Hint: You will begin by declaring a variable of the Board type. Suppose it is named vor (but you should use a better name!). When you declare a variable such as var and you do not put parentheses after the name of the variable, C++ will automatically call the default constructor. You do not need to explicitly call the default constructor. You should delete the call to the bourdinit function Buard var: Hint: Suppose you used to call a function named boardeur with a parameter of type Board as the first parameter. Now instead you want to call a function named fund for an instance of the Board class, such as var. In this case, you first give the name of the variable, then a dot, then the name of the function, and then any parameters in parentheses. Suppose the old code was boardFunc(var, values for other parameters); then the new code should be var.fune values for other paranclers) 9. Write interface specifications for the four phle functions in the Buard class. Use the format described in class and in Section 4a of the anline notes. You do not have to write interface specifications for the private functions. - Reminder: Interface specifications are written for other programmers who want to use your module. Part C: The AvailableTiles Class [40% = 26% test program + 4% code] In Part C. you will create and document a class named Avallahietiles. The class will keep track of the five tiles that are available for the players to buy and the cast for each. At the start, five tiles will be chosen randomly. Whenever a tile is removed, the higher numbered tiles will be moved down and a random new tile will be added at the end. For example, suppose we refer to the available tiles as, J. K, L, M. Also suppose that tile k was removed and a new tile (referred to as N) was picked randomly to be added. Then the revised list of available tiles would be t. J. IM, N. When the tiles are moved, their costs move with them. Note: A tile is actually a three-part object with owner, genus, and species member variables--we are referring to them by single letters for convenience here. Note: When you remove the tile from the available tiles list, a new tile will be placed in the last nosition of the www.cs.uregina.ca/anima/115/Terms/202710/Assignments/Assignment3/Assignment3.htm Part C: The AvailableTiles Class [40% = 26% test program + 4% code] In Part C, you will create and document a class named Availablefiles. The class will keep track of the five tiles that are available for the players to buy and the cost for each. At the start, five tiles will be chosen randomly. Whenever a tile is removed, the higher numbered tiles will be moved down and a random new tile will be added at the end. For example, suppose we refer to the available tiles as I, J, K, L, M. Also suppose that tile i was removed and a new tile (referred to as N) was picked randomly to be added. Then the revised list of available tiles would be T., L, M, N. When the tiles are moved, their costs move with them. Note: A tile is actually a three-part object with owner, genus, and species ember variables-we are referring to them by single letters for convenience here. Note: When you remove the tile from the available tiles list, a new tile will be placed in the last position of the list. . By the end of Part C, your Availableriles class will have the following pubize member functions. AvailableTiles () : void print () const; int getCost (unsigned int index) const; const Tile getTile (unsigned int index) const; void replaceAt (unsigned int index); You will also have the following private member function void setRandomTile (unsigned int index); Perform the following steps: 1. In AvailableTites.n, declare an unsigned integer constant named AVAILABLE TTLL_COUNT for the number of available tiles. It should have value 5. Since it is constant, the number of available tiles never changes 2. Create the Available: les class. It should have member variables that store the available tiles and tile costs. One way to do this is to have two arrays of the same length with the first array of the le type and the second array of the int type. 3. Copy in the function prototypes. 4: In AvailableTiles.cpp, write the implementation for the set Randomtile function. You should construct a tile and copy it (with an assignment operator =) into the specified position in the available tiles list. You should also set the corresponding cost. The owner member variable of the tile will be set to NO CYNER by the title noints tiles. Choose a random fm the preconditions with asserts. 7. Write the implementation for the replaceat function. It should move the tiles that have higher indexes one spot down the array and call a function to set the last tile position in the list to a random bile. Add an assert enforced precondition that requires the index parameter to be strictly less than the number of tiles. Reminder: Also move the costs when you move the tiles. Hint: You can assign objects, such as Tiles, with the assignment statement, just like any other variable. Sometimes this is referred to as copying the objects. For example: MyClass c1; Myclass c2; cl - 2; // this is legal Example: Suppose the user selects position 2. Then copy the tile from position 3 into position 2 (using an assignment statement =) and copy the cost from position 3 to position 2. Then copy the tile from position 4 to position 3 and copy the cost from position 4 to position 3. Then set position 4 to be a random tile. Example: Suppose the user selects position 0. Then copy the tile from position 1 into position (also cost), then copy the tile from position 2 to position 1 (also cost), then copy the tile from position 3 to position 2 (also cost), then copy the tile from position 4 to position 3 (also cost). Then set position 4 to be a random tile. Example: Suppose the user selects position 4. None of the tiles need to be copied. Set position to be a random tile. Hint: You should be able to write a lor loop that does any of the above examples. 8. Test your Availabler le module using the Teal Availablerts es3.car program provided. Part D: improve the main Function (10% output] n Part D, you will use your Available les class in the main function. Instead of simply placing tiles, players will buy them from a list of available tiles. If the player doesn't have enough money, he/she will not be able to buy the tile. 1. Add an AvailableTiles variable to your main function Print it out after printing the board but before printing whose turn it is. Use one of your functions from the Avaliabletles class to print it. Hint: Since the board is a variable of a class type, you will print the board by writing the variable name, then a dot, then the name of the print function, and then parentheses containing any parameters -2 After the player chooses a valid cell to place atile in, the player should program should ask the player to choose a tile to place buy so that it can be placed there. To do so, the program should first ask which tile by index the player wants to put there buy and read in the player's answer. If the index is invalid, print a failure message. Otherwise, if the player does not have enough money to pay the cost for that tile, print a failure message. Otherwise, add the tile to the game board, reduce the player's money, remove the tile from the available tiles list, and print a success message. parameters After the player chooses a valid cell to place a tile in the player should program should ask the player to choose a tile to plaee-buy so that it can be placed there. To do so, the program should first ask which tile (by index) the player wants to put there buy and read in the player's answer. If the index is invalid, print a failure message. Otherwise, if the player does not have enough money to pay the cost for that tile, print a failure message. Otherwise, add the tile to the game board, reduce the player's money, remove the tile from the available tiles list, and print a success message. Hint: To add a tile to the game board, first retrieve it from the available tiles list by using the gettle function and then store it in the game board by using the set. At function. Remember to use dot notation to call these functions. . . Note: When you remove the tile from the available tiles list using the replaceat function, a new tile will be placed in the last position of the list. Note: You may assume that the player enters an integer for the tile index. In other words, you do not have to handle all types of incorrect input. If the player does not succeed in placing a tile, remove the first tile (the one in position C) from the available tiles list Hint: Create a bool variable and set it before asking the player for a cell. Then change the value if the player successfully adds a tile. If the variable still has its original value after all the checks, then the player failed to place a tile. Formatting (-10%) 1. Neatly indent your program using a consistent indentation scheme. 2. Put spaces around your arithmetic operators: - x + 3; 3. Use symbolic constants, such as BOARD SIZE, when appropriate. 4. Include a comment at the top of Main.cpp that states your name and student number. 5. Format your program so that it is easily readable. Things that make a program hard to read include: Very many blank lines. If more than half your lines are blank, you probably have too many. The correct use of blank lies is to separate logically distinct sections of your program: Multiple commands on the same line. In general, don't do this. You can if it makes the program clearer than if the same commands were on separate lines. Uninformative variable names. For a local variable that is only used for a few lines, it doesn't really matter. But a variable that is used over a larger area (including all global variables and field names) should have a name that documents its purpose. Similarly, parameters should have self documenting names because the function will be called elsewhere in the program, Submission Submit a complete copy of your source code. You should have the following files with exactly these names: 1. AvailableTiles.h - 5. Format your program so that it is easily readable. Things that make a program hard to read include: Very many blank lines. If more than half your lines are blank, you probably have too many. The correct use of blank lies is to separate logically distinct sections of your program. Multiple commands on the same line. In general, don't do this. You can if it makes the program clearer than if the same commands were on separate lines. Uninformative variable names. For a local variable that is only used for a few lines, it doesn't really matter. But a variable that is used over a larger area (including all global variables and field names) should have a name that documents its purpose. Similarly, parameters should have self-documenting names because the function will be called elsewhere in the program. Submission Submit a complete copy of your source code. You should have the following files with exactly these names: 1. AvailableTiles.h 2 AvailableTiles.cpp 3. BoardSiznih 4. BoardSize.cpp 5. Board.h 6. Board.cpp 7. Celltd. 8. Celltd.cpp 9. Dice.h 10. Dice.cpp 11. Main.cpp 12. Tile.h 13. Tile.cpp Note: A Visual Studio . xin file does NOT contain the source code, it is just a text file. You do not need to submit it. Make sure you submit the.cpp files and files. Note: You do not need to submit the test programs or the Player 1 and Playe-.cpp files. The marker has those already If possible, convert all your files to a single archive (.zip file) before handing them in Do NOT submit a compiled version Do NOT submit intermediate files, such as o Debug folder e Release folder ipch folder 0.o files anch, .sdf, or .db files Do NOT submit a screenshot

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Second International Conference Acids Hue City Vietnam March 2010 Proceedings Part 1 Lnai 5990

Authors: Manh Thanh Le ,Jerzy Swiatek ,Ngoc Thanh Nguyen

2010th Edition

3642121446, 978-3642121449

More Books

Students also viewed these Databases questions

Question

Show that P(A|B) + P(A|B) = 1.

Answered: 1 week ago

Question

1 3 8 .

Answered: 1 week ago

Question

Identify how culture affects appropriate leadership behavior

Answered: 1 week ago