Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions