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): *bottom of post*

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.

Main Program
The main() method is responsible for verifying two command-line arguments. The first is the transaction file, the second is an error log file. All errors encountered with transactions will be logged to that file (see below).
It is recommended that you create two addition methods:

private static Account findAccount(Vector<Account> a, String acctNo)
and
private static void performTrans(Vector<Account> a, String action, PrintWriter log)

The first method will assist you in finding an account in the vector that is to have the transaction applied to it. The findAccount() method should return null if the account is not found in the Vector.The second method will free the main() method of the responsibility of the parsing of the transaction components.

All of these methods should be defined in d5.java.
Transaction Processing:
You will need to process transactions from a data file. Each transaction will have its components
separated by colons so you can use a split() method call. Each transaction will have different component counts.

The possible transactions are: create, debit, credit and report.
Here is an example transaction file:

create:checking:14-748658:First Niagara:John Smith:2000
create:credit:1234678965438765:First Card:Agnes Jones:5000
report
debit:14-748658:500
debit:1234678965438765:700
credit:14-748658:25
report


Details of the transactions:
● All accounts should be stored in a single Vector<Account> after they are created.
● New credit cards have a zero balance and the credit limit is specified in the create transaction.
● New checking accounts have the balance specified in the create transaction.
● A debit is a subtraction in all cases.
● A credit is an addition all cases.
● A debit must be denied when there is insufficient funds or greater than available credit.
● The credit card availableCredit must be accurately maintained.
● All data from a report transaction is to be sent to the screen.
● Any errors encountered should be written to the log file.
An example error log is as follows:

Invalid account: debit:10-839723:200
Transaction denied: debit:1234567898765432:600
An example report should include all the components shown:
Account Summary:
Checking account #10-3784665
Bank: Chase
Name on account: Joe Holder
Balance: 1526.33
Credit Account #1234567898765432
Bank: First Card
Issued to: Bob Badger
Credit Limit: 4000
Balance: 3500.00
Available credit: 500.00
Checking account #11-3478645
Bank: Dime
Name on account: Melissa Martin
Balance: 1030.00
End account summary.

The use of foreach loops is very helpful in this project. The code to perform the transactions will make use of several if/else-if/else blocks. Be sure to understand the use of compareTo() and/or compareToIgnoreCase() for processing the transactions.


******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 your question is?

And your question is?

This looks like a tutorial to me.

This looks like a tutorial to me.

It looks like someone posting their homework assignment, to me.

Homework without any attempt to solve it.

Thread closed!

You more then welcome to repost your question, but you are expected to show some work on this not just copy & paste assignment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.