Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago