Question: TASKS ON THE FOLLOWING JAVA FILE (INHERITANCE) public abstract class Card { protected String name; protected String website; protected String helpline; protected String cardID; protected
TASKS ON THE FOLLOWING JAVA FILE (INHERITANCE) public abstract class Card { protected String name; protected String website; protected String helpline; protected String cardID; protected int points; /** * Create a new Card issued by the Shop. * @param name The name of the shops. * @param website The website of the shop. * @param helpline The helpline of the shop. * @param cardID The ID of the card. * @param points The available points on the card. */ public Card(String name, String website, String helpline, String cardID, int points) { // You need to implement this constructor } /** * @return the name */ public String getName() { return name; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the website */ public String getWebsite() { return website; } /** * @param website the website to set */ public void setWebsite(String website) { this.website = website; } /** * @return the helpline */ public String getHelpline() { return helpline; } /** * @param helpline the helpline to set */ public void setHelpline(String helpline) { this.helpline = helpline; } /** * @return the cardID */ public String getCardID() { return cardID; } /** * @param cardID the cardID to set */ public void setCardID(String cardID) { this.cardID = cardID; } /** * @return the points */ public int getPoints() { return points; } /** * @param points the points to set */ public void setPoints(int points) { this.points = points; } /** * calculates the point for each card against a purchase * but we really don't know what * to do here because card category is not defined. */ public abstract void calculatePoints(double purchaseAmount); } 1. Whenever possible, write a singleconcrete(or normal) class. Provide all data andimplementation for all operations.
2. When you cannot provide a reasonable default implementation for one of your methods(that applies to all subclasses), you need anabstract class. In this case, declare yourclass as abstract and for the methods you cannot implement declare them as abstract anddelegate the responsibility to subclasses.
3. If a subclass isabstract, its parent should also be abstract. Why? The subclass makesthe parent class an incomplete type. You should not be able to gonew Parent()withoutcompleting it. More complex code may use this feature, but it should be avoided as muchas possible.
4. When you just want to specify the behaviour of an ADT, you declare aninterface. Youshould not define data in your interface. You should only define methods without an imple-mentation (abstract methods). These will be implemented by any class that implementsthis interface.
You should implement the following:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
