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

Use the Card class as a superclass to implement this hierarchy of related classe

ID: 3546595 • Letter: U

Question

Use the Card class as a superclass to implement this hierarchy of related classes:

Class

Data

IDCard

ID   number

DebitCard

Card   number, PIN

DriverLicense

Expiration   year

Replace the implementation of the format method for the three subclasses. The methods should produce a formatted description of the card details. The subclass methods should call the superclass format method to get the formatted name of the cardholder.

Upload the files - IDCard.java, DebitCard.java, and DriverLicense.java .

Also, override the isExpired method in the driver license class.  The method itself exists in the Card class.  I'm aware of my asker rating, but do realize I'm very new to this and I rated one response late so it went down to 67% from 99% because I've only asked a couple of questions.  Points will be rewarded to the best answerer and I will choose it ASAP.  


Here's what I have thus far:


Superclass

public class Card{

  private String name;

  

  public Card(){

    name = " ";

  }

  

  public Card(String n) {

    name = n;

  }

  

  public String getName(){

    return name;

  }

  

  public boolean isExpired(){

    return false;

  }

  

  public String format(){

    return "Card holder: " + name;

  }

  

}



Subclass

public class IDCard extends Card{

  private String idNumber;

    

    public IDCard(){

     super();

     idNumber = " ";   

  }

  

  public IDCard(String n, String id){

    super(n);

    idNumber = id;

  }

  

  public String getIDNumber(){

    return idNumber;

  }

  

  public String format(){

    String result = super.format();

    result += " ID Number:  " + idNumber;

    return result;

  }

}

Class

     

Data

     

IDCard

     

ID   number

     

DebitCard

     

Card   number, PIN

     

DriverLicense

     

Expiration   year

  

Explanation / Answer

###############DebitCard.java#####################


public class DebitCard extends Card{

private String CardNumber, PIN;


public DebitCard() {

super();

CardNumber = " ";

PIN = " ";

}


public DebitCard(String num, String pin) {

super(num);

CardNumber = num;

PIN = pin;

}


public String getCardNumber() {

return CardNumber;

}


public void setCardNumber(String cardNumber) {

CardNumber = cardNumber;

}


public String getPIN() {

return PIN;

}


public void setPIN(String pIN) {

PIN = pIN;

}


public String format() {

String result = super.format();

result += " Card Number: " + CardNumber+" PIN : "+PIN;

return result;

}

}


#####################DriverLicense.java#####################

import java.util.Date;



public class DriverLicense extends Card{

private Date expirationYear;


public DriverLicense() {

expirationYear= new Date();

}


public DriverLicense(Date year) {

super(year.toString());

}

@Override

public boolean isExpired() {

return super.isExpired();

}

}