2023 verview In this assignment you will convert some of your existing types to classes Players will also have | Assignment Collections

Computer Science 2023 C++ Need Help In 12 Hours

2023 verview In this assignment you will convert some of your existing types to classes Players will also have | Assignment Collections

 

verview
In this assignment, you will convert some of your existing types to classes.  Players will also have to pay for the tiles they want to place, and there will be a list of tiles available to buy.

The purpose of this assignment is to give you practice working with classes.  For Part A, you will convert the tile module to an encapsulated class.  For Part B, you will convert the board module to another encapsulated class.  For Part C, you will add a third class to store the available tiles.  For Part D, you will change your main function so that the players buy tiles from a list of available tiles.

Requirements
Start by creating a new project (or new folder, etc.) for Assignment 3.  Do not just modify Assignment 2.  If you are using Visual Studio, create a new project and copy in the code files (.h and .cpp) from Assignment 2.  Do not ever copy a Visual Studio project.  If you do, it will get all mixed up between the two of them and Bad Things will happen.

Part A: Convert the Tile Module to a Class [35% = 24% test program + 11% code]
In Part A, you will convert the Tile 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 genus1,
           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:

Convert the Tile record to a class.  The fields should become private member variables.
Convert the Tile-associated functions to member functions in the interface (i.e., .h) and implementation (i.e., .cpp)  files.  The tilePrint*Char 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*Char 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.
Remove the Tile parameter from all the functions.  Inside the functions, update the member variables to not use dot notation.  For example, tile.genus should become plain genus.
Add a default constructor that sets the owner to NO_OWNER, the genus to GENUS_MONEY, and the species to 1.  Remember to add the function prototype.
Note: If we don’t declare a default 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.
Add a precondition to the non-default constructor that requires the genus1 parameter to be strictly less than GENUS_COUNT.  Use an assert 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.
Add a private const member function named isInvariantTrue to check the class invariant.  It should return true if the tile genus is strictly less than GENUS_COUNT and false if it is the same or greater.
Check the class invariant at the end of every non-const public member function.  For the Tile class, this is both constructors and setOwner.  At the end of each of these functions, use an assert to make sure that isInvariantTrue returns true:
     assert(isInvariantTrue());
The purpose of this is to ensure that these functions do not leave the Tile in an invalid state.  The const 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.
Check the class invariant at the start of every public member function except the constructors.  Use an assert to make sure that isInvariantTrue returns true.  The purpose of this is to ensure that the Tile in a valid state when the function is called.
Reminder: Don’t check the invariant in private functions.
Test your Tile module using the TestTile3.cpp program provided.  As always, you will need TestHelper.h and TestHelper.cpp.
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 Board 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 CellId& cell_id) const;

·              void setAt (const CellId& cell_id,
                 const Tile& value,
                 unsigned int owner);

You will also have the following private member functions:

·              void printColumnNameRow () const;

·              void printBorderRow () const;

·              void printEmptyRow () const;

·              void printDataRow (int row) const;

Perform the following steps:

Declare a Board class.  It should have a 2D array of Tiles as a private member variable.  Remove the Board typedef.
Convert the existing function prototypes to member functions or copy in the ones shown above.  Update the implementation file to match.
Convert the boardInit function into a default constructor.  When assigning values to the board array, use the non-default Tile constructor.  The syntax is:
array_name[i][j] = Tile(put parameters here);
Change the getAt and setAt functions to take a const reference to a CellId as a parameter instead of a row and a column.
Add a precondition to the getAt and setAt functions, enforced by an assert.  It should require that the cell is on the board.
Hint:  You have a function to check that a cell is on the board.
Add a parameter to the setAt function for the new tile’s owner.  The function should set the new tile on the board to have that owner.  And a precondition that the tile parameter does not already have an owner.
Hint:  Use a function from the Tile class to change the owner.
Test your Board class using the TestBoard3.cpp program provided.
Update your main function to use the new Tile and Board classes.  It should run as before.
Write interface specifications for the four public functions in the Board class.  Use the format described in class and in Section 4a of the online 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 AvailableTiles.  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 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 I, J, 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 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 position of the list.

By the end of Part C, your AvailableTiles class will have the following public 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:

Declare an unsigned integer constant named AVAILABLE_TILE_COUNT for the number of available tiles. It should have value 5. Since it is constant, the number of available tiles never changes.
Create the AvailableTiles 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.
Copy in the function prototypes.
Write the implementation for the setRandomTile 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_OWNER by the tile constructor.  In this assignment, all the available tiles will be points tiles.  Choose a random value from 1, 2, or 3, with an equal chance of each, and name it P for points. The tile species should be P and the tile cost should be P * P.  Give the function a precondition that requires the index parameter to be strictly less than the number of available tiles.  Enforce the precondition with an assert.
Write the implementation for the default constructor.  It should call sendRandomTile for each tile.
Write the implementation for the print function.  It should print one line for each tile, showing the tile index, the tile itself, and the tile cost with a dollar sign (‘$’).  One acceptable format is ”  N: TTT   $C”, where N is the index, TTT is the tile, and C is the cost.
Reminder: A function for printing a tile in a three-character format, here shown as TTT, was developed in Assignment 2 and converted to a member function in Part A above.
Write the implementations for the getCost and getTile functions.  Both functions should have a precondition that requires the index parameter to be strictly less than the number of tiles.  Enforce the preconditions with asserts.
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.  Add an assert-enforced precondition that requires the index parameter to be strictly less than the number of tiles.
Hint: You can assign objects with the assignment statement, just like any other variable.  For example:
MyClass c1;
MyClass c2;
c1 = c2;  // this is legal
Reminder: Also move the costs when you move the tiles.
Test your AvailableTiles module using the TestAvailableTiles3.cpp program provided.
Part D: Improve the main Function [10% output]
In Part D, you will use your AvailableTiles 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.

2.       After the player chooses a valid cell to place a tile in, the player should choose a tile to place there.  The program should first ask which tile (by index) the player wants to put there 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.

·         Note: When you remove the tile from the available tiles list, a new tile will be placed in the last position of the list.

3.       If the player does not succeed in placing a tile, remove the first tile (the one in position 0) 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%]
Neatly indent your program using a consistent indentation scheme.
Put spaces around your arithmetic operators:
x = x + 3;
Use symbolic constants, such as BOARD_SIZE, when appropriate.
Include a comment at the top of Main.cpp that states your name and student number.
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.   BoardSize.h

4.   BoardSize.cpp

5.   Board.h

6.   Board.cpp

7.   CellId.h

8.   CellId.cpp

9.   Dice.h

10. Dice.cpp

11. Main.cpp

12. Tile.h

13. Tile.cpp

o   Note: A Visual Studio .sln 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 .h files.

o   Note: You do not need to submit the test programs or the Player.h and Player.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

o   Release folder

o   ipch folder

o   *.o files

o   *.ncb, *.sdf, or *.db files

·         Do NOT submit a screenshot

Important Notes 

1) Solution 2 will help u

2) Internet se copy paste nahi karna hai , Original work chaiye 

PFA

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational