Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Define an abstract superclass called Member under which there are three concrete

ID: 3627546 • Letter: D

Question

Define an abstract superclass called Member under which there are three concrete classes: Gold, Silver, and
Basic.
Private instance variables in class Member include
1. a String memberID
2. a String lastName
3. a String firstName
4. an integer currentTotalPoints
Private static (class) variable in class Member: noOfPointsPerCert. 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:

---------------------------------------------------------------------------------------------
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:
(1) Asks for member ID (you can assume that the member ID keyed in is a valid one).
(2) Displays the member ID, member name, his/her membership level, current total points of this member.
(3) Asks for the purchase amount.
(4) Update the total points of this member according to the level of membership by calling the appropriate
method of the appropriate class.
(5) Displays the new total number of points.
(6) If the member is a Gold member, call the appropriate method to see if he/she has taken his/her annual
present yet. If no, display “Annual present not yet received.” If yes, display “Annual
present already received.”
(7) Then the system displays the above main menu again.
Choice 2 Chosen:

If a user chooses 2, then the system:
(1) Asks for member ID (you can assume that the member ID keyed in is a valid one).
(2) Displays the member ID, member name, his/her membership level and current total points available,
number of points needed per certificate, and the maximum number of dining certificates that he/she can
redeem now.
(3) Asks for the number of certificates this member would like to get (you can assume that the number
keyed in is a positive integer).
(4) Call the appropriate method of the appropriate class to do the following: see if this request is feasible.
(a) If this request is feasible, then the system displays the result (no. of certificates awarded) and
the newest available points remaining in the member’s account after this redemption.
(b) If this request is not feasible, then the system displays the message that this cannot be done and
tell him/her to try again with more points later. (Since the emphasis is inheritance and
polymorphism here, we use an “all or nothing” redemption policy for simplicity.)
(5) If the member is a Gold member, call the appropriate method to see if he/she has taken his/her annual
present yet. If no, display “Annual present not yet received.” If yes, display “Annual
present already received.”

(6) Finally, the system displays the above main menu again.

i am having trouble with writing a subclass for GOLD and Silver. HELP PLEASE!!!!

Explanation / Answer

I didn't know what the purchaseValue-to-Points ratios were, so I made them up; replace them with whatever is accurate. public class Gold extends Member{ private boolean annualPresentGiven; public Gold(String mID, String lN, String fN, int cTP, boolean aPG){ super(mID, lN, fN, cTP); annualPresentGiven = aPG; } public void addPoints(double purchaseValue){ super.setCurrentTotalPoints((int)(purchaseValue * .25)); } public void setAnnualPresentGiven(boolean newAPG){ annualPresentGiven = newAPG; } public boolean getAnnualPresentGiven(){ return annualPresentGiven; } } public class Silver extends Member{ public Silver(String mID, String lN, String fN, int cTP){ super(mID, lN, fN, cTP); } public void addPoints(double purchaseValue){ super.setCurrentTotalPoints((int)(purchaseValue * .15)); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote