Question: Create a class Card that represents a general type of membership card. The Card class will have one instance variable called name which will be

Create a class Card that represents a general type of membership card. The Card class will have one instance variable called name which will be of type String. Write a default constructor which sets name to (an empty String). Write a parameterized constructor which receives a single String parameter and sets name to this given parameter. The Card class must also implement the following methods:

 public boolean isExpired(){} 

which always returns false. And:

 public String toString(){} 

which returns the String "Card Holder: " concatenated with the name instance variable.

Create a class DebitCard which subclasses the Card class. The DebitCard class will have two instance variables of type int: cardNumber & pin.

Write a default constructor which calls the constructor of its superclass, passing it the string Jane Doe. The default constructor must also initialize cardNumber to 00000000 and pin to 0.

Write a parameterized constructor which takes three parameters: A String for the card name, an int for the cardNumber, and an int for the card pin. The parameterized constructor which calls the constructor of its superclass, passing it the name parameter. The parameterized constructor must also initialize cardNumber and pin using the passed parameters. The DebitCard class must also implement the following methods:

A getter for the cardNumber instance variable

A function isPin which takes a single int parameter and returns true (a Boolean value)

if the passed int parameter is equal to the pin instance variable and false if it is not

A toString method which calls the super classs toString method and concatenates it

with " Card Number: " and the value of the cardNumber instance variable.

Create a class IDCard which subclasses the Card class. The IDCard class will have one instance variable called IDNumber which will be of type int.

Write a default constructor which passes the String Jane Smith to the superclass constructor and sets IDNumber to 0.

Write a parameterized constructor which takes a String for name and an int for anIDNumber, passing the superclass constructor the name parameter and initalizing the IDNumber instance variable using the passed anIDNumber parameter.

Write a getter method for IDNumber

Write a toString method which calles the super classs toString method and

concatenates it with " ID Number: " and the value of the IDNumber instance variable.

1. Consider using the following Card class that represents a general type of membership card. public class Card{

private String name;

public Card(){ name = "";

Create a class DriversLicense which subclasses the IDCard class. The DriversLicense

}

class will have one instance variable called expirationYear which will be of type int. WritepaudbelfiacultCcaorndst(ruScttrorinwghicnh)pa{sses calls the superclass constructor and sets

expirationnYaemaer to= 1n9;69. }

Write a parameterized constructor which takes an int for aYear, a String for name,

and an int for anIDNumber, passing the superclass constructor the name and

public String getName(){

anIDNumber parameters and initializing the expirationYear instance variable using

return name;

the passed aYear parameter.

}

Write a method getExpirationYear which returns the value of the expirationYear instance variable.

public boolean isExpired(){ Write a mreethtoudrinsEfxapilrsede;which returns false if the expirationYear is greater than or

}

} }

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

equal to 2017. It returns false otherwise. Write a toString method which calls the super classs toString method and

public String format(){

concatenates it with " Expriation Year: " and the value of the expirationYear instance variable.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!