JKL Restaurant maintains a members’ club for its customers. There are three levels of membership: (1) Basic, (2) Silver, and (3) Gold. A certain member has to be exactly a Basic, Silver, or Gold member at any point in time. Whenever a member spends money at JKL, he/she gets points and as these points are accumulated, one can redeem one or more $20 dining certificates. Each Gold member can also get an annual appreciation present from the restaurant.
Activity Gold Silver Basic
Getting points Rounded up nearest integer value Rounded up nearest integer Rounded up nearest integer
(purchase value *110%) (purchase value *105%) of purchase
---------------------------------------------------------------------------------------------------------------------------------------------
Redeeming a dining
certificate Use 300 points use 300 points use 300 points
---------------------------------------------------------------------------------------------------------------------------------------------
Getting annual
appreciation present yes no no
Define an abstract superclass called Member under which there are three concrete classes: Gold, Silver, and Basic.
Private instance variables in class Member include
Private static (class) variable in class Member: noOfPointsPerCert.
you declare this private attribute:
Please initialize it to 300 when private static int noOfPointsPerCert = 300;
This static variable will also be inherited by each subclass. Do not declare an instance variable for holding the membership type of a particular member.
The class Member should have a 4-parameter constructor that accepts four input parameter values for each of the instance variables above. The class Member should have a set method and a get method for each of the instance variables above. It should also have a static set method and a static get method for the static variable noOfPointsPerCert. These are all concrete methods. These are to be inherited and used by all those subclasses.
The class Member should have an abstract method addPoints(double purchaseValue). When implemented in a subclass, it should add the correct number of points to a member’s account with the raw incoming purchase value for getting points, according to the rules of adding points for that level of membership. The class Member should have a concrete method redeemCertificates(integer noOfCertificatesRequested). There can be two different approaches for writing this method. The first approach: it calculates the number of certificates that a member can redeem. If the member does not have enough points to redeem the requested number of certificates, it should tell the user a sorry message and refuse to grant any certificates. If the redemption is possible, it should deduct the correct number of points from a member’s account correctly according to the number of certificates desired and the rule of redeeming them for that level of membership. It should also display the number of certificates redeemed and display the number of points remaining. This concrete method is to be inherited and used by all subclasses.
The second approach: Another way to code the concrete method redeemCertificates(integer noOfCertificatesRequested)is: it calculates the number of certificates that a member can redeem. If the member does not have enough points to redeem the requested number of certificates, it should return a 0 integer value to the caller statement. This means none has been redeemed. The caller statement receives the value and the test application should tell the user a sorry message and refuse to grant any certificates. If the redemption is possible, this method, redeemCertificates(integer noOfCertificatesRequested), should deduct the correct number of points from a member’s account correctly according to the number of certificates desired and the rule of redeeming them for that level of membership. It should return the number of certificates actually redeemed to the caller statement in the test application. Then the test application should also display the number of certificates redeemed and the number of points remaining. This concrete method is to be inherited and used by all subclasses. You can choose either approach and code the test application correspondingly to work with your choice of approach for writing this redeemCertificates(integer noOfCertificatesRequested) method.
Implement a subclass of Member called Gold. It should inherit all the attributes and methods from Member.
It should also have an additional boolean instance variable called annualPresentGiven. If a Gold member has not chosen to receive this annual present this year, this flag value for this Gold member is false. Otherwise, it is true.
As the class Gold has five instance variables, it should have a 5-parameter constructor. It inherits all concrete methods in Member and it should implement the abstract method addPoints(double purchaseValue) of class Member.
The class Gold should have two specific methods defined in it: (1) setAnnualPresentGiven(boolean value) and (2) getAnnualPresentGiven(). When a Gold member is either adding points or trying to redeem certificates (whether successful or not), the system checks whether this member has already taken his/her present this year via calling the method getAnnualPresentGiven(). If the boolean value returned is a false value, this means this member has not received the present this year. Then the system displays the message “Annual present not yet received.” If the value of this attribute is true, then the system displays “Annual present received.” Do not add an instance variable for holding the membership type of a particular member.
Follow a similar procedure for defining the subclass Silver with its own rules and values. Similarly, following a similar procedure for defining the subclass Basic with its own rules and values. However, they do NOT need the extra instance variable annualPresentGiven. They do NOT need the two methods:
(1) setAnnualPresentGiven(boolean value) and (2) getAnnualPresentGiven(). In order to perform all the required functions, the above classes may need other methods not described here. Write a Java application called JKLTest to use the above classes to perform the following. In method main of this application, create the following members with the following initial instance values:
Member ID Last Name First Name
20013 Jones David
20023 Shoemaker Lisa
20033 Miller James
20043 Keller Richard
20053 Brown Anna
Current Total
Points
4,000
1,000
12,890
50
3,729
Level of
Membership
Basic
Silver
Gold
Gold
Silver
Annual Present
Already Redeemed
n/a
n/a
false
true
n/a
Then the application lets a human user perform transactions: either a member accumulates more points or wants to redeem dining certificates until the human user chooses to quit. Repeated operations for the same member are possible. The main menu should be displayed as follows:
JKL Restaurant Membership Management Main Menu:
1. Add points to a member’s account
2. Redeem dining certificates for a member
3. Quit
Choice 1 Chosen:
If a user chooses 1, then the system:
Choice 2 Chosen: If a user chooses 2, then the system:
Choice 3 Chosen: The system displays “Bye” and ends the execution. Hints: