We will simulate a basic hotdog stand empire. - IMPORTANT NOTE: I already have t
ID: 3909532 • Letter: W
Question
We will simulate a basic hotdog stand empire. - IMPORTANT NOTE: I already have the Money class and makefile done. I mostly need the HotDogStand class and the Non-Member function.
Requirements: General Requirements
• You will be submitting eight (8) files for this assignment – Be sure to split your code among the files appropriately
• The name of your executable shall be hw
• Create two classes and name their types HotdogStand and Money
• All relevant classes, functions, and data shall be placed in a namespace called MyAwesomeBusiness
• Use initialization sections where possible for all constructors
• Only functions that are explicitly intended to write to the screen should do so, unless you are printing an error message
Money Class Requirements
• Negative amounts of Money shall be stored by making both the dollars and cents negative
• The Money class shall have four (4) constructors
– A default constructor that initializes your Money object to $0.00
– A constructor that takes two integers, the first for the dollars and the second for the cents
*
This constructor must validate the two integers to ensure that a positive and negative value
are not mixed. A value of zero can be considered either positive or negative. If a positive
and negative value are provided, a default Money object shall be returned instead.
– A constructor that takes one integer, for an even dollar amount
– A constructor that takes one double, and can assign dollars and cents accordingly
• int getPennies() const
– Returns the equivalent amount of money held by the calling object as a number of pennies
• bool isNegative() const
– Returns true if your amount of money is negative
• The following functions will be removed:
– NOTE: You may wish to keep the logic of some of these functions and move them somewhere
else
1
– void add(const Money &m)
– void subtract(const Money &m)
– bool isEqual(const Money &m) const
– void print() const
• The following operators shall be overloaded as member operators
– Unary minus (negative sign)
– Prefix & Postfix increment (Increment dollars by one)
– Prefix & Postfix decrement (Decrement dollars by one)
• The following operators shall be overloaded as friend operators
– Addition of two Money objects
– Multiplication of Money and int
– Multiplication of int and Money
– Multiplication of Money and double
– Multiplication of double and Money
– Less than
– Less than or equal to
– Greater than
– Greater than or equal to
– Equality
– Inequality
*
NOTE: All comparative operators shall compare two Money objects
– Insertion
– Extraction
• The following operator shall be overloaded as a non-member, non-friend operator
– Subtraction between two Money objects
• The Money class shall have two private data members
– An integer that represents how many dollars you have.
– An integer that represents how many cents you have.
HotdogStand Class Requirements
• The HotdogStand class shall have three (3) constructors
– A default constructor with the following values
*
Price of a hotdog = $3.50
*
Daily dogs sold = 0
*
Total stand dogs sold = 0
2
*
Hourly wage of $7.25
*
Hotdog supply = 60
* Max hotdogs = 60
* Wholesale hotdog cost = $0.15
*
Your starting cash will be a negative value representing the cost of buying your maximum
amount of hotdogs
– A constructor that takes a Money object representing the price of a hotdog. Initialize the remaining
values as follows:
*
Daily dogs sold = 0
*
Total stand dogs sold = 0
*
Hourly wage of $8.00 IF the price of a hotdog is greater than $3.50, or $7.25 otherwise
*
Hotdog supply = 30 IF the price of a hotdog is greater than $3.50, or 60 otherwise
* Max hotdogs = see hotdog supply
* Wholesale hotdog cost = $0.50 IF the price of a hotdog is greater than $3.50, or $0.15
otherwise
*
Your starting cash will be a negative value representing the cost of buying your maximum
amount of hotdogs
– A constructor that takes a double representing the price of a hotdog. Initialize the remaining
values according to the second constructor
• const Money getCash() const
– This returns the total cash the HotdogStand has
• const Money getPrice() const
• int getDailyDogsSold() const
– ATTN: This function is changed from the previous assignment
– This returns the number of hotdogs sold by the stand in one day
• void replenishSupplies()
– You must use your cash to buy hotdogs so that you have your maximum supply
– You will always buy up to your maximum supply, even if your cash goes negative
• void payWorker()
– The wages of your HotdogStand employee are deducted from your cash daily
• void dailyReset()
– Resets the appropriate private data members in order to correctly simulate another day
• const Money getStandRevenue() const
– This calculates the total money made by selling hotdogs
• void setPrice(double price)
3
• void sellHotdog()
– Increments all appropriate data members accordingly
• static int getNumStands()
• static int getTotalHotdogsSold()
• static const Money getTotalRevenue()
• The HotdogStand class shall have twelve (12) private data members
– A Money object that will represent how much cash the stand has
– A Money object that will represent the price of a hotdog
– An integer that will describe how many hotdogs a stand has sold in a single day
– An integer that will describe how many cumulative hotdogs a stand has sold
– A Money object representing the hourly wage of your stand employee
– A constant that represents how many hours your employee works in a day, initialized to 8
– An integer that represents your hotdog supply
– An integer that represents the maximum amount of hotdogs you are allowed to have
– A Money object that represents the wholesale cost of a hotdog
– A static integer that represents the total number of HotdogStand objects
– A static integer that represents the total number of hotdogs sold
– A static Money object that represents total revenue for all HotdogStand objects
Non-Member Requirements
• Define the following non-member functions in the MyAwesomeBusiness namespace:
– void runSimulation(std::vector& franchises, int days)
*
This function runs the simulation for an end-user specified number of days
– void printRundown(const vector& franchises)
*
ATTN: This function is changed slightly from the previous assignment
*
This function will print the summary that is shown in the sample run below
main() Requirements
• Declare a vector of HotdogStand objects in your main function
• The end-user shall be prompted for how many hotdog stands they own
• The end-user will then be prompted for how many of those hotdog stands sell fancy hotdogs
• If and only if the above input is greater than zero (0), the end-user shall be prompted for the price of
the fancy hotdogs
– The end-user may type the price with or without the $
4
• The end-user will be prompted to specify for how many days the simulation will run
• The simulation is then run and the output is printed to the screen
Simulation Requirements
• The last n stands are always fancy, where n is the number of stands designated as fancy by the
end-user
• Regular hotdog stands (price of hotdog is <= $3.50) can sell a random number in the range 20 - 60
(inclusive) hotdogs a day
• Fancy hotdog stands (price of hotdog is > $3.50) can sell a random number in the range 1 - 30
(inclusive) hotdogs a day
• At the end of a day, a hotdog stand must purchase as many hotdogs as they sold to reach their
maximum supply
• At the end of a day, cash will be deducted to pay the employee for that day’s work
• Totals for cumulative hotdogs sold, cumulative revenue, and total cash is only displayed at the of the
simulation
• All money amounts in the daily table must be right-aligned
A sample run of your program shall look like this (Your sales numbers will not match):
NOTE: There are some subtle changes to the output that are required (right alignment of Money columns,
cumulative summary at end of simulation)
Welcome!
How many hotdog stands do you own? 3
How many of these sell classy hotdogs? 1
How much does a classy hotdog cost? $8.99
How many days will you simulate? 3
Stand Sales Price Revenue Remaining Cash
===== ===== ======= ========= ==============
1 53 $3.50 $185.50 $110.55
2 29 $3.50 $101.50 $30.15
3 6 $8.99 $53.94 ($28.06)
Stand Sales Price Revenue Remaining Cash
===== ===== ======= ========= ==============
1 58 $3.50 $203.00 $246.85
2 52 $3.50 $182.00 $146.35
3 19 $8.99 $170.81 $69.25
Stand Sales Price Revenue Remaining Cash
===== ===== ======= ========= ==============
1 30 $3.50 $105.00 $289.35
2 33 $3.50 $115.50 $198.90
3 20 $8.99 $179.80 $175.05
TOTALS 300 $1297.05 $663.30
Stands: 3
$
Explanation / Answer
main.cpp #include "money.hpp" #include "hotdogStand.hpp" #include #include #include void printRundown(const HotdogStand franchises[], int num); int main() { HotdogStand franchises[10]; double hotdogsPrice; //Money object that represents the price of a hotdog static int totalNumberOfHotdogStand; //static integer that represents the total number of HotdogStand objects static int totalNumberOfHotdogSold; //static integer that represents the total number of hotdogs sold static Money totalRvenueOfHotdogStand; //static Money object that represents total revenue for all HotdogStand objects std::cout 0) { for(int i = totalNumberOfHotdogStand; i > 0; i-- ) { for(int j = 0; jRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.