Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java program to demonstrate the use of inheritance, polymorphism, interf

ID: 3633602 • Letter: W

Question

Write a Java program to demonstrate the use of inheritance, polymorphism, interfaces and transaction processing. This program will also use the Vector class.

Class Definitions:
You are to begin with the following class (Account.java):

public class Account implements AccountAction {
protected String accountNo, institution, name;
protected double balance;
public Account (String accountNo, String name, String institution,
double balance) {
this.name = name;
this.accountNo = accountNo;
this.balance = balance;
this.institution = institution;
}
public String getAccount() {
return accountNo;
}
/* interface is implemented at this level, but is not used to
manipulate the account directly. The subclasses will override
these. */
public boolean debitAccount(double amt) {
return false;
}
public boolean creditAccount(double amt) {
return false;
}
}

and interface (AccountAction.java):

public interface AccountAction {
public boolean debitAccount(double amt);
public boolean creditAccount(double amt);
}

Make sure these are in different files. You will create two additional files that are the classes CreditCard and CheckingAccount. The two classes will be subclasses of the Account class defined above.

The CheckingAcount class needs no additional instance variables and the CreditCard class will need two additional instance variables:

private int creditLimit;
private double availableCredit;


The CheckingAccount and CreditCard classes should define at least one constructor each. In addition they should override the method toString() and override the debitAccount() and creditAccount() interface methods.

Explanation / Answer

public class Account implements AccountAction { protected String accountNo, institution, name; protected double balance; public Account (String accountNo, String name, String institution, double balance) { this.name = name; this.accountNo = accountNo; this.balance = balance; this.institution = institution; } public String getAccount() { return accountNo; } /* interface is implemented at this level, but is not used to manipulate the account directly. The subclasses will override these. */ public boolean debitAccount(double amt) { return false; } public boolean creditAccount(double amt) { return false; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote