Java Assignment I need help with design. This material is somewhat more theoreti
ID: 3910929 • Letter: J
Question
Java Assignment
I need help with design.
This material is somewhat more theoretical than that of previous topics, so instead of writing a program for this assignment, you are going to work on a design. Specifically, your task is to design a class to represent a credit card. Try to design your class such that it only includes fields and methods relative to a credit card itself, without branching out into related functionality, like that of a bank or a consumer. At the same time, try to make your class as complete as possible, so that it can be used in any application that involves a credit card. To complete this assignment, you will turn in a text document (Word or PDF) with the following information: • A list of the fields and methods of your class. For fields you will need to specify the type, the accessibility (private, public, etc), whether it is a static or instance field, and any limitations on the values (non-negative, always less than some other value, etc). For the methods, you will need to supply the return type and parameter type list. • A free-form description of what each field and method is meant to do, with explanation of any potentially confusing design decisions.
This is what I have so far. No code is needed for this.
Public class CreditCard
Members:
Private String name
Private String password
Private Date date_of_issue
Private Date date_of_expiry
Private Double balance
Private static final Double creditLimit = 5000; // for 5000Dollars
Private Double TransactionLimit;
private Boolean isActive;
constructor
CreditCard(Name, Password, balance, TransactionLimit)
//set card to active, set the name, password, balance and transactionLimit
//set date_of_issue to today and date_of_expiry to 10 years later
Methods
public debit(password, amount)
//Debit the amount, if password matches and balance is greater than the amount to be //withdrawn
public credit(amount)
//Credit the amount, sum the amount to balance
public getNameOnCard()
//return name of the card holder
public isCardWorking()
//return if date_of_expiry is after today's date and if card is in active state
public getBalance()
//return the balance
public getCreditLimit()
//return the creditLimit
public getTransactionLimit()
//return the transactionLimit
public isActive()
//return true is card is active
public setName(name)
//set card holder name
public setPassword(pass)
//set password for the card
Explanation / Answer
I think debit happens on the account linked to the credit card and not the card itself. So instead of having methods for crediting and debiting money , we need to have the account number of the account linked to the card. And debit and credit methods need to go in Account Class(which is none of our concern right now)
therefore we should'nt have methods like debit credit and balance as these are supposed to be methods of the Account class.
We need one private instance variable namely , the linked account number.
private final long linkedAccNo ; // and corresponding getters and setters
final because once a card is linked to an acc , it can never be shifted to another account. It can only be cancelled.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.