Starting from:
$30

$24

Homework 01 Solution

What to submit




All of your .cpp and .h files that make up your solution



A makefile to compile your .cpp and .h file into an executable named ​hoarding.out



Description




Add




The ability to upgrade a property with houses and hotels as well as the ability to sell those upgrades



Rolling again if you roll doubles



The ability to auction properties if someone decides not to purchase a property they land on



Upgrading Properties




Time it took Matthew: 50 mins




Feature Description







Whenever a player has the ability to roll dice or leave the game they also have the ability to purchase or sell upgrade on any property within in a set that they fully own. A player can purchase or sell as many upgrades as they want during a turn. When a player upgrades a property they add one house to it. If the player has enough enough houses as specified in the rules file and they upgrade their property, the houses are removed and a hotel is added in place of them.




Requesting an upgrade




During a player’s turn they may press 2 to upgrade a property. If they choose to upgrade a property all of the properties on which they can upgrade should be displayed to them. A property is upgradeable if




The user owns all of the properties in the set



The user has enough money to purchase the upgrade on that property



If the “Must Build Evenly” rule is set then only the property within a set that has the fewest upgrades may be upgraded



Properties should be shown from lowest property id to highest and within a set from lowest intraset id to highest. After each property display the upgrade cost in [] For example if the

player owned ​Oriental Avenue, Vermont Avenue, Connecticut Avenue ​(set id 1) and Park Place and Boardwalk ​(set id 7) then they would see the following when upgrading a property




Which property do you want to upgrade?

Oriental Avenue [$​50]



Vermont Avenue [$​50]



Connecticut Avenue [$​50]



Park Place [$200]



Boardwalk [$200]



Your choice:




If a user does not have any properties that they can upgrade they should be shown "You don't have any properties that you can upgrade"




Purchasing a property does ​not​end a players turn or advance the turn count.







Selling Upgrades




During a players turn they may choose to sell a property back to the bank for half the cost they purchased it at by pressing 3. The interface for selling an upgrade is the same as for purchasing an upgrade but instead of saying ​Which property do you want to upgrade? ​instead say​ Which property do you want to sell? ​If the player has no upgrades you should say:​ You have no upgrades to sell.




If the Must Build Evenly Rule is enabled, the player may only sell upgrades from properties within a set that have the most upgrades on it.




If a player would go bankrupt to a player during their turn but they have upgrades on a property, they must sell their upgrades back to the bank. They must continue selling upgrades back to the bank until they either have enough money to pay off their debt or they have sold all of their upgrades. If at this point they are still in debt, they then go bankrupt.




Calculating rent




Rent for a property that has houses on it as calculated as




rentF orOneHouse * 2NumberOfHousesOnT heP roperty − 1 . Rent for a hotel is the the rent for the hotel as given in the board file.




Calculating Net Worth




A players net worth is now the sum of their cash, the cost of their properties, and the cost of the upgrades on their properties.




Updates to the display




The format to display the state of the game is now




Space Number | Space Name | Owner | Upgrades | Players




For each house that a player has on a property a ​h​should be displayed. For each hotel on a property a ​H​should be displayed







Updates to Inputs




1 is for rolling dice



2 is for buying upgrades



3 is for selling upgrades



4 is for leaving the game






Rolling Again on Doubles




Time it took Matthew: 20 minutes




Feature Description




Whenever a user rolls doubles (both dice have the same values) they roll again up until they reach the ​Max Doubles ReRolls limit​ specified in the rules files.




Updates to Rules Files




There is now a new entry in the rules file at the end called ​Max Doubles ReRolls. It​

has the form​ Max Doubles ReRolls: N, where​ N is the maximum number of times the user gets to roll again if they roll doubles on their turn.​ If​ it is 0, then if they roll doubles they don’t get to roll again. If 1 they can roll again once, 2 twice, 3 three times, etc. They only get to keep rolling on their turn ​IF​they keep rolling doubles. For example, if N is 3 and the user rolls two 3’s they get to reroll. If they then roll a 5 and a 4 their turn is over because they did not roll doubles.




Auctioning Properties




Time it took Matthew: 30 minutes




Feature Description




If the Auction Properties rule is enabled and player lands on property and chooses not to buy it or is unable to buy it, the property goes up for auction. The auction starts at $1. Players take turns bidding on the property starting from Player 1. A player must bid at least one more dollar than the current max bid. If a Player does not wish to make a bid then they can enter a number less than the next bid to remove themselves from the auction. If a player’s total cash is less than the next bid they are automatically removed from the auction. Bidding continues until only a single player is left in the auction. They are the winners of the auction and get the property for the price they bid on it. If all players decline to bid on the property it remains unowned.




Interface




When an auction starts you will display

Starting the auction for​​NameOfProperty




During each players turn to bid you will either say




"No one has bid on NameOfProperty [$propertyCost] yet"



If no one has bid on the property yet



The current bid for NameOfProperty [$propertyCost] is $highestBid by highestBidder’s Name

If someone has bid on the property



Followed by




CurrentBidder’s Name, enter a bid of at least (highestBid + 1)




to




bid on the property or a value less that that to leave the




auction




Your bid:










Input




Input will always be valid. A player will not bid more money than they have.

More products