Question
Use the following specification to code a complete C++ module named CoffeeOrder. enum class CoffeeType { AmericanDark, AmericanRegular, Espresso, IceCoffee}; Your CoffeeOrder class includes at
Use the following specification to code a complete C++ module named CoffeeOrder.
enum class CoffeeType { AmericanDark, AmericanRegular, Espresso, IceCoffee};
Your CoffeeOrder class includes at least the following data-members:
- the address of a C-style null-terminated string of client-specified length that holds the barcode number of the coffee order (composition relationship)
- Valid Barcode: any string that contains a dash '-'
- the type of coffee order using one of the enumeration constants defined above, defaulting to IceCoffee
Public Member Functions: - default constructor
- a custom constructor that receives as parameters:
- the type of coffee order (optional)
- the address of a C-style null-terminated string containing the coffee order barcode number
If the parameters are valid, this constructor stores them in the current object's instance variables. If the client has omitted the type of coffee input argument, this constructor assumes that the type of coffee order is AmericanRegular.
- A function named CoffeeOrderCost
If the current object is not in an empty state, this function calculates the coffee order cost according to the following rules:
- AmericanDark coffee order costs $5
- AmericanRegular coffee order costs $3.50
- Espresso coffee order costs $7.5
- IceCoffee coffee order costs $4
Plus a tax of 13% and then returns a value representing the coffee order cost. For example, if the coffee order has barcodes "AAA-111" and is an 'IceCoffee', the cost is $4.52.
If the current object is in an empty state, this function should generate an exception of type 'std::string'
- A class function named 'totalNoOfOrders, returns the number of Espresso coffee orders that currently exist and have not yet been destroyed
Include in your design all special member functions required to manage your objects.
You are allowed to add as many private members as you see fit.
Your design should not generate any memory leaks, should meet the C++17 standard and should apply best practices.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started