CSCE 155
Assigned:
Due: Start of Class,
Note: This assignment is to be
completed individually - collaboration is strictly prohibited.
Points: 100 points
In Homework Assignment 4, you created an application that implements a grocery store. In this assignment, you are required to extend the application using inheritance and polymorphism.
Now, we want to differentiate the customers into several types: general customers, cardMember customers and senior customers. The cardMember customer class and the senior customer class should be inherited from the general customer class. For a cardMember customer, it has two additional attributes: a cardID (a String data member) and a discount percentage (e.g., 5.3%). For a senior customer, it has two additional attributes as well: age (an integer) and discount percentage (e.g., 2.7%). The customer class that you have built in Homework Assignment 4 should be the general customer class.
For different types of customers, your program should correctly compute the total amount of their purchases based on the discount percentages they have, and show their bills accordingly. For example, in the bill of a cardMember customer, it should reflect that the customer is a cardMember and show the customer’s cardID.
Add a function to compute the total sales of the grocery store. Here, you should use polymorphism. The idea is that you should define the method called “computeTotalPurchaseAmount” to compute the total amount of purchases of each customer in the classes of general customer, cardMember customer and senior customer, respectively. (Note that here we require the same method header or prototype to be used in all three implementations!) Then in the GroceryStore class, you are required to have a method that computes the total sale of the entire grocery store by summarizing all the purchases of all the customers.
Your new ShoppingCard class is required have new features to accommodate the new types of customers. Please see Figure 1 as an example.

Figure 1. Example of a new ShoppingCart class. If the member type is not selected, then it
is assumed that the customer is a general customer.
Your new GroceryStore class is required have a new button and a new text field. The new button is for “Total Sale”. When the user clicks on this button, GroceryStore will compute the total sale of all purchases of all customers and output the amount in the new text field.
In addition to the classes you created in Homework Assignment
4, you should include several new classes:
To test your program, input at least 5 different customers, and among these at least 2 customers make more than 2 purchases. Some of these customers should be of the Customer class, some should be of the CardMemberCustomer class, and some should be of the SeniorCustomer class. Then test to compute the total sales of the grocery store. Turn in your test results.
A sample homework 4 solution will be provided as soon as possible.
Add an option to your application that allows the user to query for the information of a specific customer by name. So, when this query window pops up, the user can enter a customer’s name (and only the customer’s name), and then the window will display the information of the customer. How to display is your choice.
Notice you are required to use polymorphism to implement this. That is, you are required to define and implement a method called printCustomerInfo for all different classes of customers.