Send help I don\'t know where to even start. I just need a general outline and I
ID: 3861346 • Letter: S
Question
Send help I don't know where to even start. I just need a general outline and I can fill out the specifics but yeah please help. My professor can't teach and I am struggling :( Assigment is everything below
Assignment
Write an application that creates one Bank with three different bank account types: SavingsAccount, CheckingAccount, and IRAAccount. The Bank class implements the Transaction interface. The accounts extend the abstract Account class.
Part 1: Relationship Diagram
Sketch the relationship diagram. Identify any has-a, is-a, and can-do relationships. Include the name of the class or interface, any class variables and methods.
Part 2: Java files
Implement the classes based on the documentation files. These are provided with the assignment in a compressed file (.zip) called Lab5Doc.zip.
To test your code, run BankDriver application. MODIFY IT TO READ FROM A FILE!
Driver output:
Program 5, Patty Kraft, masc0777
Creating accounts...
Customer: Waterford Ellingsworth, Savings account 1 Balance: $4350.00
Customer: Bethanie Treadwell, Checking account 2 Balance: $500.00
Customer: Ira Standish, IRA Savings account 3 Balance: $50000.00, Disbursement Age=59, Early Withdrawal Penalty=0.1
Performing transactions...
Savings account 1 Balance: $4550.00
Checking account 2 Balance: $286.87
IRA Savings account 3 Balance: $50000.00, Disbursement Age=59, Early Withdrawal Penalty=0.1
Updating accounts...
Savings account 1 Balance: $4559.10
Checking account 2 Balance: $286.52
IRA Savings account 3 Balance: $55000.00, Disbursement Age=59, Early Withdrawal Penalty=0.1
Extra Credit
Create a DebitCard account that extends CheckingAccount. Add public methods debit() and credit(); set transaction fee to 0.35. Be efficient! Reuse code.
Input help
Read the input from a comma separated file. Let 1=SavingsAccount type, 2=CheckingAccount type, 3=IRAAccount type, and (if implemented) 4=DebitCard type.
Use a Scanner object containing a line from the file and call useDelimiter():
Customer: Debi Cardashian, Debit Card Checking account 4 Balance: $5100.00 Debit Card Checking account 4 Balance: $5100.00
Scanner infile = new Scanner(customers); // where customers is a File object Scanner s2 = new Scanner(infile.nextLine());
s2.useDelimiter(",");
if (s2.hasNextInt()) accountType = s2.nextInt(); // etc. reading other fields
Explanation / Answer
some general outline about application.
1. relations
All SavingsAccount , CheckingAccount , Account type, are all IS-A account hence they extend abstract class Acount.
A Bank HAS- A ACCOUNTS hence it will has an arraylist of type account to hold accounts.
A bank CAN-DO transactions hence it implenents trasnsaction interface.
skeleton of your application shall look something like following
-----------------------------------------------
package sample;
public abstract class Account
{
private String accountHolderName;
private double balance;
public Account(String name,double bal)
{
this.accountHolderName=name;
this.balance=bal;
}
public String toString()
{
return String.format(this.accountHolderName+","+this.balance);
}
public String getAccountHolderName()
{
return this.accountHolderName;
}
public double getBalance()
{
return this.balance;
}
public void setAccountHolderName(String n)
{
this.accountHolderName=n;
}
public void setBalance(double bal)
{
this.balance=bal;
}
/// all the varaibles that every account must have as per your assignement
}
class CheckingAccount extends Account
{
public CheckingAccount(String name, double bal) {
super(name, bal);
// TODO Auto-generated constructor stub
}
//specific attributes for this class
}
class SavingsAccount extends Account
{
public SavingsAccount(String name, double bal) {
super(name, bal);
// TODO Auto-generated constructor stub
}
//specific attributes for this class
}
class IRAAAccount extends Account
{
public IRAAAccount(String name, double bal) {
super(name, bal);
// TODO Auto-generated constructor stub
}
//specific attributes for this class
}
----------------------------------
package sample;
import java.util.ArrayList;
public class Bank implements Transaction
{
String name;
public Bank(String name)
{
this.name=name;
}
ArrayList<Account> accounts=new ArrayList<Account>();
public void addAccount(Account acc)
{
accounts.add(acc);
}
public void removeAccount(Account acc)
{
accounts.remove(acc);
}
public void DisplayAllAccounts()
{
for(int i=0;i<accounts.size();i++)
{
System.out.println(accounts.get(i));
}
}
public void searchAccountsWithBallance(double bal)
{
for(int i=0;i<accounts.size();i++)
{
if(accounts.get(i).getBalance()>=bal)
{
System.out.println(accounts.get(i));
}
}
}
@Override
public void credit(Account name,double amt) {
// TODO Auto-generated method stub
for(int i=0;i<accounts.size();i++)
{
double newBalance=0;
if(accounts.get(i).getAccountHolderName().equals(name))
{
newBalance=accounts.get(i).getBalance()+amt;
accounts.get(i).setBalance(newBalance);
}
}
}
@Override
public void debit(Account name,double amt) {
// TODO Auto-generated method stub
for(int i=0;i<accounts.size();i++)
{
double newBalance=0;
if(accounts.get(i).getAccountHolderName().equals(name))
{
newBalance=accounts.get(i).getBalance()-amt;
accounts.get(i).setBalance(newBalance);
}
}
}
}
--------------------------
package sample;
public interface Transaction {
void credit(Account name,double amt);
void debit(Account name,double amt);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.