Use inheritance to create base and child classes. Utilize multiple classes in the same program. ...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Use inheritance to create base and child classes. Utilize multiple classes in the same program. • Perform standard input validation • Implement a solution that uses polymorphism Problem: Disneyland has begun a service that allows guests at the park to pre-order drinks and pick them up at a designated time so as to avoid long concession lines. Guests that spend more than $50 (cumulatively) become preferred customers and are awarded discounts on their orders. A program is needed to track the amount spent by each customer and promote them to preferred customer when they have accumulated $50 in purchases. Classes: • Customer (base class) o Members . First name (string) Last name (string) ▪ Guest ID (string) Amount spent (float) Methods • Overloaded Constructor . Accessors . Mutators Preferred Customer - Gold (derived from customer) o Member • Discount Percentage (float) Methods Overloaded Constructor (chained to base class constructor) ■ Accessor . Mutator Preferred Customer - Platinum (derived from customer) o Member • Bonus bucks (float) o Methods Overloaded Constructor (chained to base class constructor) Accessor Mutator Details: • The price of the drink is determined by the type of drink and the amount of ounces ordered o Soda - $0.20 o Tea - $0.12 o Fruit punch - $0.15 Each drink will come in a cylindrical container o Small ● ● . ● ● . Medium o Large . Diameter - 4 in. Height - 4.5 in. 12 oz. . Diameter - 4.5 in. Height -5.75 in. 20 oz. Diameter - 5.5 in. Height - 7 in. ▪ 32 oz. The container can be personalized with different Disney graphics o The total price of the personalization is determined by the price per square inch o The area covered by the graphic will be just the outer surface area of the cylinder o The surface area of the cylinder will not include the top and bottom of the cylinder Preferred customer information and regular customer information will be stored in files and will be read into memory before the program processes orders. o The preferred customer file may be empty or may not exist. o In both cases, the respective customer array should not be created until a customer reaches preferred status. Regular customers and preferred customers will be held in 2 separate arrays. (-10 points if not) o Both gold and platinum customers will be stored in the same array (preferred) o Do not use an array list for this project The arrays will never be larger than the actual number of customers in each category. Orders will be read from a file. After processing an order, if a regular customer has spent at least $50, promote the customer to preferred status (gold). o The preferred customer array will be resized to add one more element. ● ● . After processing an order, if a regular customer has spent at least $50, promote the customer to preferred status (gold). o The preferred customer array will be resized to add one more element. o Add the new preferred customer into the open element at the end of the preferred customer array. o Resize the regular customer array and remove the customer data that was promoted to preferred status. o Do not rearrange the order of the data in either array. o Remember that each array should be no bigger than the number of customers at that level. Gold preferred customers get a discount based on how much they have spent overall o $50 = 5% discount o $100 = 10% discount o $150 15% discount o This discount applies as soon as the above target value is obtained. . Example 1: customer has spent $40 previously. The customer places an order for drinks that amounts to $10. The customer is immediately placed in preferred status and given a 5% discount. The new amount spent is $49.50 Example 2: customer has spent $90 previously. The customer places an order for drinks that amounts to $10. However, the customer has a 5% discount as a preferred customer. The customer has a total of $99.50 after the discount is applied and is not moved to the next bracket for preferred customers If the customer placed an order for $11, the new total with the discount would be $100.45. The customer is immediately placed into the new bracket and a 10% discount is given instead. The new amount would be $99.90 and the customer would be at the 10% discount level. After processing an order, if a gold preferred customer has spent at least $200, promote the customer to platinum status. o Replace the gold member object in the array with a platinum member object o Update the bonus bucks if necessary (see below) Platinum preferred customers receive bonus bucks instead of a discount. o For every $5 over $200, the customer receives 1 bonus buck (worth a dollar) ▪ When an order is placed, bonus bucks are only earned for every multiple of $5 above the beginning total For example, if a customer has spent $217, and makes a purchase of $12, the customer would earn 2 bonus bucks (one for $220 and one for $225) o The bonus buck is applied to the next order o The total spent does not include any bonus bucks used o The bonus buck is applied to the next order o The total spent does not include any bonus bucks used o If an order costs $5 and a bonus buck is used, the total sales increases by $4. Platinum status is applied when the total amount spent is $200 after gold member discounts are applied. o If the gold discount puts the customer under the $200 threshold, the customer remains at gold status. Input: Input data will be stored in three files: preferred.dat, customers.dat and orders.dat. The total number of lines in each file will be unknown. . Preferred.dat will hold the data for preferred customers and customers.dat will hold the data for regular customers. Both files should be read at the beginning of the program to establish the preferred customer and regular customer arrays respectively. Preferred.dat may be empty or may not exist. In such cases, there should not be a preferred customer array created before reading the orders. Each line of preferred.dat will be formatted as follows (except for the last line of the file which may not have a newline character). The data will be listed in the following order on each line with a space between each field. There will be no invalid data on any line. customer ID first name last name ● amount spent ● discount or bonus bucks newline Amount spent will indicate if the customer is gold or platinum. Discount and bonus bucks will be an integer value. The number will be followed by a percent sign if the customer is a gold member. Each line of customer.dat will be formatted as follows (except for the last line of the file which may not have a newline character). The data will be listed in the following order on each line with a space between each field. There will be no invalid data on any line. ● . . ● Orders.dat will hold all orders to process. Each valid line of the file will be formatted as follows (except for the last line of the file which may not have a newline character). A valid line will consist of data listed in the following order with a space between each field. There may be invalid data on any line. If a line contains invalid data, ignore everything on the line. . . customer ID first name last name . amount spent newline customer ID (string) size (character) S, M, or L drink type (string) - soda, tea or punch square inch price (float) quantity (integer) newline Invalid data: Invalid data can consist of any of the following: incorrect number of fields (more or less than 5) incorrect ID - doesn't match an existing ID of a customer • incorrect value option for size or drink type garbage characters - character present in value that is outside the data type's acceptable character set o example: a letter character in a value for a field with a numeric data type Output: At the end of the program, write the regular customer data and preferred customer data to their respective files. Use the proper format as listed above in the Input section. There will be no output to the screen. Use inheritance to create base and child classes. Utilize multiple classes in the same program. • Perform standard input validation • Implement a solution that uses polymorphism Problem: Disneyland has begun a service that allows guests at the park to pre-order drinks and pick them up at a designated time so as to avoid long concession lines. Guests that spend more than $50 (cumulatively) become preferred customers and are awarded discounts on their orders. A program is needed to track the amount spent by each customer and promote them to preferred customer when they have accumulated $50 in purchases. Classes: • Customer (base class) o Members . First name (string) Last name (string) ▪ Guest ID (string) Amount spent (float) Methods • Overloaded Constructor . Accessors . Mutators Preferred Customer - Gold (derived from customer) o Member • Discount Percentage (float) Methods Overloaded Constructor (chained to base class constructor) ■ Accessor . Mutator Preferred Customer - Platinum (derived from customer) o Member • Bonus bucks (float) o Methods Overloaded Constructor (chained to base class constructor) Accessor Mutator Details: • The price of the drink is determined by the type of drink and the amount of ounces ordered o Soda - $0.20 o Tea - $0.12 o Fruit punch - $0.15 Each drink will come in a cylindrical container o Small ● ● . ● ● . Medium o Large . Diameter - 4 in. Height - 4.5 in. 12 oz. . Diameter - 4.5 in. Height -5.75 in. 20 oz. Diameter - 5.5 in. Height - 7 in. ▪ 32 oz. The container can be personalized with different Disney graphics o The total price of the personalization is determined by the price per square inch o The area covered by the graphic will be just the outer surface area of the cylinder o The surface area of the cylinder will not include the top and bottom of the cylinder Preferred customer information and regular customer information will be stored in files and will be read into memory before the program processes orders. o The preferred customer file may be empty or may not exist. o In both cases, the respective customer array should not be created until a customer reaches preferred status. Regular customers and preferred customers will be held in 2 separate arrays. (-10 points if not) o Both gold and platinum customers will be stored in the same array (preferred) o Do not use an array list for this project The arrays will never be larger than the actual number of customers in each category. Orders will be read from a file. After processing an order, if a regular customer has spent at least $50, promote the customer to preferred status (gold). o The preferred customer array will be resized to add one more element. ● ● . After processing an order, if a regular customer has spent at least $50, promote the customer to preferred status (gold). o The preferred customer array will be resized to add one more element. o Add the new preferred customer into the open element at the end of the preferred customer array. o Resize the regular customer array and remove the customer data that was promoted to preferred status. o Do not rearrange the order of the data in either array. o Remember that each array should be no bigger than the number of customers at that level. Gold preferred customers get a discount based on how much they have spent overall o $50 = 5% discount o $100 = 10% discount o $150 15% discount o This discount applies as soon as the above target value is obtained. . Example 1: customer has spent $40 previously. The customer places an order for drinks that amounts to $10. The customer is immediately placed in preferred status and given a 5% discount. The new amount spent is $49.50 Example 2: customer has spent $90 previously. The customer places an order for drinks that amounts to $10. However, the customer has a 5% discount as a preferred customer. The customer has a total of $99.50 after the discount is applied and is not moved to the next bracket for preferred customers If the customer placed an order for $11, the new total with the discount would be $100.45. The customer is immediately placed into the new bracket and a 10% discount is given instead. The new amount would be $99.90 and the customer would be at the 10% discount level. After processing an order, if a gold preferred customer has spent at least $200, promote the customer to platinum status. o Replace the gold member object in the array with a platinum member object o Update the bonus bucks if necessary (see below) Platinum preferred customers receive bonus bucks instead of a discount. o For every $5 over $200, the customer receives 1 bonus buck (worth a dollar) ▪ When an order is placed, bonus bucks are only earned for every multiple of $5 above the beginning total For example, if a customer has spent $217, and makes a purchase of $12, the customer would earn 2 bonus bucks (one for $220 and one for $225) o The bonus buck is applied to the next order o The total spent does not include any bonus bucks used o The bonus buck is applied to the next order o The total spent does not include any bonus bucks used o If an order costs $5 and a bonus buck is used, the total sales increases by $4. Platinum status is applied when the total amount spent is $200 after gold member discounts are applied. o If the gold discount puts the customer under the $200 threshold, the customer remains at gold status. Input: Input data will be stored in three files: preferred.dat, customers.dat and orders.dat. The total number of lines in each file will be unknown. . Preferred.dat will hold the data for preferred customers and customers.dat will hold the data for regular customers. Both files should be read at the beginning of the program to establish the preferred customer and regular customer arrays respectively. Preferred.dat may be empty or may not exist. In such cases, there should not be a preferred customer array created before reading the orders. Each line of preferred.dat will be formatted as follows (except for the last line of the file which may not have a newline character). The data will be listed in the following order on each line with a space between each field. There will be no invalid data on any line. customer ID first name last name ● amount spent ● discount or bonus bucks newline Amount spent will indicate if the customer is gold or platinum. Discount and bonus bucks will be an integer value. The number will be followed by a percent sign if the customer is a gold member. Each line of customer.dat will be formatted as follows (except for the last line of the file which may not have a newline character). The data will be listed in the following order on each line with a space between each field. There will be no invalid data on any line. ● . . ● Orders.dat will hold all orders to process. Each valid line of the file will be formatted as follows (except for the last line of the file which may not have a newline character). A valid line will consist of data listed in the following order with a space between each field. There may be invalid data on any line. If a line contains invalid data, ignore everything on the line. . . customer ID first name last name . amount spent newline customer ID (string) size (character) S, M, or L drink type (string) - soda, tea or punch square inch price (float) quantity (integer) newline Invalid data: Invalid data can consist of any of the following: incorrect number of fields (more or less than 5) incorrect ID - doesn't match an existing ID of a customer • incorrect value option for size or drink type garbage characters - character present in value that is outside the data type's acceptable character set o example: a letter character in a value for a field with a numeric data type Output: At the end of the program, write the regular customer data and preferred customer data to their respective files. Use the proper format as listed above in the Input section. There will be no output to the screen.
Expert Answer:
Answer rating: 100% (QA)
Answer include include include class Customer protected stdstring firstName stdstring lastName stdstring guestID float amountSpent public Customercons... View the full answer
Related Book For
Data Structures and Algorithms in Python
ISBN: 978-1118290279
1st edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Posted Date:
Students also viewed these programming questions
-
A telephone manufacturer produced and sold 2 0 0 0 telephones and made a net income of $ 7 0 , 0 0 0 last year, with total revenues of $ 5 0 0 , 0 0 0 . The manufacturer s break - even volume is 1 2...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
Anon Amus Inc. operates a woodworking shop that makes tables and chairs. He has 25 employees working 40 hours per week and he has 750 hours per week available in machine time. Ralph knows that he...
-
What is the difference between the average cost of production and the marginal cost of production?
-
For solutions of a weak acid, a graph of pH versus the logarithm of the initial acid concentration should be a straight line. What is the magnitude of the slope of that line?
-
Vogue Skincare has 5,000 shares of \(5 \%, \$ 20\) par value preferred stock and 100,000 shares of \(\$ 1.50\) par common stock outstanding. During a three-year period, Vogue declared and paid cash...
-
One-pound coffee cans are filled by a machine, sealed, and then weighed by a local coffee store. After adjusting for the weight of the can, any package that weighs less than 16 oz is cut out of the...
-
8. 10 Points True Machines, Inc. would like to develop a plan for building and shipping their Premium Generator product to satisfy customer orders. The Murrysville plant can produce 17 units and the...
-
On January 1, Year 1, the Vine Company purchased 60,000 of the 80,000 ordinary shares of the Devine Company for $80 per share. On that date, Devine had ordinary shares of $3,500,000, and retained...
-
A 250 itre tank used for liquid storage is configured as in figure below. Its mathematical model and its dynamic behaviour follow first order kinetics are as follows: General 1" order system: dy +y=...
-
When two identical waves of red light ( wavelenght = 6 6 0 nm ) interfere constructively, is there any change in the wavelength and frequency of the light?
-
Within the context of rapidly evolving technological landscapes and dynamic market conditions, how do leading organizations formulate and execute adaptive strategies to maintain competitive advantage...
-
Hanna Company s current asset and current liability account balances at the beginning and end of the year were as follows: December 3 1 End of Year Beginning of Year Current assets: Cash and cash...
-
Considering the evolving nature of workforce dynamics and the imperative to attract, retain, and develop top talent in competitive labor markets, how do organizations craft holistic talent management...
-
In order to determine if an increase in GDP is caused by an increase in quantities produced or by an increase in price (inflation), what aspect the economists could use ?
-
A coffee chain with a franchise in Saskatoon is interested in piloting a new beverage. The chain wants to ensure that this beverage is served at a temperature of 40 degrees Celsius. Baristas create...
-
Evenflow Power Co. is considering a new project that is a little riskier than the current operations of the company. Thus, management has decided to add an additional 1.5% to the company's overall...
-
There are eight small islands in a lake, and the state wants to build seven bridges to connect them so that each island can be reached from any other one via one or more bridges. The cost of...
-
Write a Python program that simulates a system that supports the functions of an e-book reader. You should include methods for users of your system to buy new books, view their list of purchased...
-
In similar spirit to the previous problem, augment the Sequence class with method _ _lt_ _, to support lexicographic comparison seq1 < seq2.
-
An air-conditioning chiller unit weighing \(10 \mathrm{kN}\) is to be supported by four air springs (Fig. 2.50). Design the air springs such that the natural frequency of vibration of the unit lies...
-
The maximum velocity attained by the mass of a simple harmonic oscillator is \(10 \mathrm{~cm} / \mathrm{s}\), and the period of oscillation is \(2 \mathrm{~s}\). If the mass is released with an...
-
A helical spring, when fixed at one end and loaded at the other, requires a force of \(100 \mathrm{~N}\) to produce an elongation of \(10 \mathrm{~mm}\). The ends of the spring are now rigidly fixed,...
Study smarter with the SolutionInn App