Question: Design and implement the Java code for a class to represent a credit card. Its attributes (member or instance variables) are: network - An enum

Design and implement the Java code for a class to represent a credit card.

Its attributes (member or instance variables) are:

network - An enum (CardNetwork) type consisting of one of the 4 major networks (AMEX, DISCOER, MASTER_CARD or VISA) number - The credit card number (String) cardHolder - The name of the credit card holder (owner) (String) expirationDate - The expiration date of the credit card (String) securityCode - The security code associated with the card (int)

The Credit class will have methods to:

Create a new CreditCard (given a network, card holder name, number, expiration date and security code) [constructor] getCardHolder getExpirationDate getNetwork getNumber setCardHolder equals [method to check if one CreditCard is the same as another] toString [method to turn CreditCard into a string for display], for example:

Credit Card [VISA, ************6789, John Smith, 12/2019]

(note that the credit card number only shows the last 4 digits and security code is not displayed at all)

***Be sure to demonstrate that your class performs as specified by creating a driver program (e.g. CreditCardDemo.java) to test each method***

Here is a UML class diagram to help with the design:

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!