Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++11 need guidance. Thanks We will simulate a very basic hotdog stand empire. Requirements: General Requirements You will be submitting eight (8) files for this

C++11 need guidance. Thanks

We will simulate a very basic hotdog stand empire. 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 hw03 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 With the sole exceptions being the print() function(s), no other functions should be printing to the screen unless an error message must be displayed 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 A constructor that takes one integer, for an clean dollar amount A constructor that takes one double, and can assign dollars and cents accordingly int getPennies() const Returns the equivalent amount of money as a number of pennies bool isNegative() const Returns true if your amount of money is negative void add(const Money &m) The sum shall be stored in the calling object void subtract(const Money &m) The difference shall be stored in the calling object bool isEqual(const Money &m) const void print() const This function prints the amount of Money you have; it must print a $, and always show two decimal places Negative amounts of Money shall be represented in the following manner: ($X.XX) 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 two (2) constructors A default constructor that initializes your HotdogStand object with no cash, a price of $3.50, and no hotdogs sold A constructor that takes a double, and initializes your HotdogStand object with no cash, the provided hotdog price, and no hotdogs sold const Money getCash() const This returns the total cash the HotdogStand has const Money getPrice() const int getDogsSold() const This returns the number of hotdogs sold by the stand const Money getStandRevenue() const This calculates the total money made by selling hotdogs void setPrice(double price) void sellHotdog() Increments all appropriate data members accordingly static int getNumStands() static int getTotalHotdogsSold() static const Money getTotalRevenue() The HotdogStand class shall have six (6) private data members A Money object that will represent how much money the stand has made A Money object that will represent the price of a hotdog An integer that will describe how many hotdogs a stand has sold 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 function: void printRundown(const vector &franchises, int num) * 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 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 $ The simulation is then run and the output is printed to the screen Simulation Requirements The simulation only runs through a single day The last n stands are always fancy, where n is the number of stands designated as fancy by the end-user Regular hotdog stands can sell a random number in the range 20 - 60 (inclusive) hotdogs a day Fancy hotdog stands can sell a random number in the range 1 - 30 (inclusive) hotdogs a day A sample run of your program shall look like this (Your numbers will not match): NOTE: The input file contained the following inputs: 3 1 $8.00 (Enter pressed after last input) $ ./hw02 < inputs Welcome! How many hotdog stands do you own? 3 How many of those sell classy hotdogs? 1 How much does a classy hotdog cost? $8 Stand Sales Price Revenue ===== ===== ===== ======= 1 47 $3.50 $164.50 2 24 $3.50 $84.00 3 21 $8.00 $168.00 TOTALS 92 $416.50 # of Stands: 3 $

makefile Requirements Your makefile must still include the requisite comment block Your makefile must compile each class separately Your makefile must include a clean rule Hints: The functions getCash() and getStandRevenue() will return the same amount of money in this assignment. However, it will be better to code the functions according to their descriptions It is possible to typedef a namespace. It looks something like this: namespace alias = namespace; To ensure a proper count of Hotdog Stands, you may want to look up the vector function emplace back() While not enforced in this assignment, this is a great time to practice not using directives, or at least placing them more smartly The C++11 library is much more robust than the older C library The hints from the first homework also apply here and are repeated The functions listed in the Requirements are required (shocker!), but you may find it useful to write other helper functions Converting a double to a Money object can cause rounding errors * You may want to look up the round() function Converting an amount of money to an equivalent amount of pennies makes a lot of logical work go away You can create a file that holds user inputs and use it to streamline your testing.

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

Step: 3

blur-text-image

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

Define a derivative instrument as per U.S. GAAP and as per IFRS.

Answered: 1 week ago

Question

Explain all drawbacks of application procedure.

Answered: 1 week ago