This material is somewhat more theoretical than that of previous topics, so inst
ID: 3737438 • Letter: T
Question
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 Java class to represent a credit card. Try to design your class such that it only includes fields and methods relevant 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, protected, default or package), 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.
A justification for your design based on the guidelines given in Section 13.10 of your textbook on pages 525-528.
The first two items will look somewhat similar to what was provided in the assignment description for 04. Fourth Assignment – Calculator with Methods. The justification will be somewhat similar to what was provided in the URL.java file included in this topic’s course materials (week10.jar). You do NOT need to implement your class (i.e., you do not need to write any code).
Explanation / Answer
Creditcard class:
public class CreditCard {
private String cardHolderName;
private long cardNumber;
private double accBalance;
private double cardSpendingLimit;
private int accountLevel;
public CreditCard() {
}
public CreditCard(String name,long cardNo,double balance,double limit,int level){
cardHolderName=name;
cardNumber=cardNo;
accBalance=balance;
cardSpendingLimit=limit;
accountLevel=level;
}
public String getCardHolderName() {
return cardHolderName;
}
public void setCardHolderName(String cardHolderName) {
this.cardHolderName = cardHolderName;
}
public long getCardNumber() {
return cardNumber;
}
public void setCardNumber(long cardNumber) {
this.cardNumber = cardNumber;
}
public double getAccBalance() {
return accBalance;
}
public void setAccBalance(double accBalance) {
this.accBalance = accBalance;
}
public double getCardSpendingLimit() {
return cardSpendingLimit;
}
public void setCardSpendingLimit(double cardSpendingLimit) {
this.cardSpendingLimit = cardSpendingLimit;
}
public int getAccountLevel() {
return accountLevel;
}
public void setAccountLevel(int accountLevel) {
this.accountLevel = accountLevel;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.