Question: Language: C++ You are to design a Class that will represent a restaurant order. The Class will have two public methods, one to place an
Language: C++
You are to design a Class that will represent a restaurant order. The Class will have two public methods, one to place an order and the second to calculate and display the order items and prices, the order subtotal, the tip, the tax, and the check total. The method to place the order will allow the User to enter up to 5 order items. The method is to present a Menu of items for selection. You are to create two const static, parallel arrays for the menu items, one for the item descriptions (string) and the second for the item costs (double), which, of course, will be class private data members. You are to provide 10 items for selection. You might want to find a restaurant menu online to use for your 10 items, or you may use the ones shown in the example below. You will store the items selected in another one-dimensional array. The element values of this array are the element values of the selected items in the two static arrays. You are to use a Sentinel value to terminate the items entry (one of the Menu selections) OR terminate entry after 5 items have been entered.
You are to clear the Console screen (see page 354 in the text) and present the User with a Menu of items and costs (from the two parallel arrays), two items per line. Each item shall have an integer selection number that the User will use to select the item, as an example: 1: Breakfast roll $1.75. Display a prompt following the Menu presentation to enter the next item, indicating the order item number (1 10, maximum). You must use the Screen Control features described on page 486 of the text in method presentMenu and to place the cursor at the same position for each item selection prompt message.
The second, public class method, which displays the customers check will sub-total the cost of the items ordered, calculate a tip based on the sub-total amount only, then calculate the tax, again based only on the sub-total amount, then calculate the check total as the sum of the order subtotal, the tax, and the tip. The method will display the entire order (each item description and cost), the tax, the tip, and the check total. If no items were ordered, do not display a check, but display a message indicating the order was cancelled (use the RETurn value from method placeOrder to determine this case).
Your project must meet these minimum requirements:
Name the class: RestaurantCheck
Include a Constructor that takes two arguments, the tax rate and the tip, both as a percentage: 1. Validate that the tax rate is greater than or equal to 1% (0.01) and less than or equal to 12% (0.12). If the value passed to the Constructor is invalid, set the tax rate to 0.065 2. Validate that the tip percentage is greater than or equal to 5% (0.05) and less than or equal to 20% (0.20). If the value passed to the Constructor is invalid, set the tip to 15% (0.15)
Include a Default Constructor that sets the tax rate to 0.065 (6.5%) and the tip percentage to 15% The default values and the limit values should be declared as class private, static const values.
Provide a public static class method, named testTaxRate, to test a tax rate percentage value passed to it as a parameter. The method will RETurn a bool value, true: The parameter value is valid.
Provide a public static class method, named testTipRate, to test a tip percentage value passed to it as a parameter. The method will RETurn a bool value, true: The parameter value is valid.
Name the public class method to place an order: placeOrder
Name the public class method to display the check: issueCheck
Create a private class method to display the Menu and name it: presentMenu Note: This method is called by method placeOrder to present the menu of items
Create a private class method to calculate the tax and name it: calculateTax
Create a private class method to calculate the tip and name it: calculateTip
When displaying the check, make sure all amounts have their decimal points vertically aligned and display 2 digits of precision to the right of the decimal point (all amounts are double)
These range limit values are declared as Class static const values as each RestaurantCheck object instantiated does not need its own copy of these constant values. Thus the methods can be declared static, since they will only access Class static const values.
You will need to declare the three methods placeOrder, presentMenu, and issueCheck as shown below:
placeOrder()
presentMenu()
issueCheck()
Since you must use Cursor Control in your solution, you must define a screen HANDLE data member in your class, then, in your Constructor(s), assign to it, using the Windows method GetStdHandle, a handle to the Console device. You would then define a private class method to place the cursor, passing to it the x and y coordinates for the position. That method can then use the class HANDLE data member to position the cursor using the Windows method SetConsoleCursorPosition.
Finally, all Class static const values must only be declared in the Class definition file, RestaurantCheck.h, and then initialized in the external, Class definition file, RestaurantCheck.cpp. For example: In RestaurantCheck.h: static const double MIN_TAX_RATE; In RestaurantCheck.cpp: const double RestaurantCheck::MIN_TAX_RATE = 1.0;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
