Deeds have a price and a mortgage value. You may obtain a loan from the bank for the mortgage value, but doing this precludes you from claiming rent. We therefore need an mortgaged flag.
Finally, deeds belong to someone. Since we haven't defined the Player class yet, we will use Key as a placeholder class until we are ready for the real thing.
These are all properties common to all kinds of deeds. We will therefore use a base class Deed to represent all those common properties.
The individual particularities of every kind of deed will be implemented in the derived classes PropertyDeed, UtilityDeed and StationDeed.
Since there is a lot of data associated with every Deed, we will use pointers to refer to other deeds. Therefore, we need to derive Deed from Indexable. We will then derive DeedPtr from Pointer, and finally, create a list of pointers called DeedPtrList to refer to all the other deeds in the same group.
The DeedIndex in which all the deeds are stored will contain elements of different classes. We will therefore have to implement a smarter readContents function for this class.
This is the entity relationship diagram of class hierarchy we are creating:
The existance of those class stubs will allow us to derive DeedIndex from Index. This is actually quite simple: you only need to redesign the readContents function to enable it to read the three different kinds of deeds, as the Index::writeContents function already works.
As usual, DeedIndex.h is provided... and looking at the tests can never hurt...
Finally, add the data member DeedIndex deeds to the Game class. Update Game::ReadContents and Game::writeContents, making sure you check the returncodes. Remove the Account data member but keep the Dice data member - you will need it for change 16.
This change looks like a lot of work, but it really isn't. It is required to finish this change before you can work on any other changes in this exercise.
Note the monopoly() member function returns GroupSize defined in Base.h. Note that the value all means that all group members belong to the same player, and that the values one, two and three may only be used if there is at least one group member which doesn't belong to the same player. This is because two property groups have only two members, whereas all other property groups have 3 members. It is important for determining the rent to know if all properties of the same group belong to the same player.
Once again, this change needs to be finished before the next three changes can be compiled. Once this is finished, though, the next three changes can be done simultanously
Use the data type Houses defined in Base.h to index an array of rent amounts. When reading or writing that array, first read/write the index of type Houses, then read/write the rent amount. A look at the tests will reveal more on the expected data formats.
Later, we will implement the member function build(). Since this function requires monopoly objects we haven't defined yet, we cannot implement it properly. We will therefore leave it as an empty "stub".