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

Below is my java code for a banking system. It uses interface, inheritance among

ID: 3579306 • Letter: B

Question

Below is my java code for a banking system. It uses interface, inheritance among other things. I need to make a UML diagram for it but I'm having a hard time figuring it out. If someone could make one for me or point me in the right direction i'd really appreciate it!

/********* Customer.java**********/

public class Customer {
private String firstName;
private String lastName;
private String number;
private int customerId;
  
private SavingsAccount account = new SavingsAccount();
private CheckingsAccount cAccount = new CheckingsAccount();

Customer(String firstName, String lastName, String number, int id, SavingsAccount account) { //Constructor
this.firstName = firstName;
this.lastName = lastName;
this.number = number;
this.account = account;
this.customerId = id;
}

Customer(String firstName, String lastName, String number,int id, CheckingsAccount cAccount) { //Contructor
this.firstName = firstName;
this.lastName = lastName;
this.number = number;
this.cAccount = cAccount;
this.customerId = id;
}
  
//Methods
public String getName(){
return (firstName+ " "+ lastName);
}
public String getNumber(){
return number;
}
public int getId(){
return customerId;
}
  
}

/********Account.java**********/

interface Account {
  
//Methods
public void deposit(double amount);

public void withdraw(double amount);

public double getBalance();

public int getId();
}

/************AbstractAccount.java**********/

public abstract class AbstractAccount implements Account {
protected double balance = 0;
protected int accountId;

public AbstractAccount() {} //Default Constructor

public AbstractAccount(double bal, int id) { //Constructor
if (balance >= 0) {
balance = bal;
}
else {
balance = 0;
}
accountId = id;
}

//Methods
@Override
public abstract void withdraw(double amount);

@Override
public abstract void deposit(double amount);
  
@Override
public abstract double getBalance();

@Override
public abstract int getId();

}

/***********SavingsAccount.java*************/

import java.util.Date;
import java.util.Calendar;
public class SavingsAccount extends AbstractAccount{
private Date dateCreated;
private Date preset;
  
public SavingsAccount() { //Default Constructor
super();
dateCreated = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(dateCreated);
cal.add(Calendar.MONTH, 6);
preset = cal.getTime();
}

public SavingsAccount(double balance, int id) { //Constructor
super(balance,id);
dateCreated = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(dateCreated);
cal.add(Calendar.MONTH, 6);
preset = cal.getTime();
}
public SavingsAccount(double balance, int id,Date date){ //Constructor
super(balance,id);
dateCreated = date;
Calendar cal = Calendar.getInstance();
cal.setTime(dateCreated);
cal.add(Calendar.MONTH, 6);
preset = cal.getTime();
}
  
//Methods
public String getDateCreated(){
return dateCreated.toString();
}
  
@Override
public void withdraw (double amount) //Cannot withdraw for 6 months till account creation
{
Date currentDate = new Date();
if (getBalance() < amount)
{
System.out.println("Amount is larger than current balance.");
}
if (!currentDate.after(preset)) {
System.out.println("Amount exceeds balance or account has not reached preset date.");
}
else
balance-=amount; }

@Override
public void deposit(double amount) {
balance+=amount;
}

@Override
public double getBalance(){
return balance;
}

  
@Override
public int getId(){
return accountId;
}
  

}

/************CheckingsAccount.java***********/

public class CheckingsAccount extends AbstractAccount{
private final double overdraftLimit=1000;
  
public CheckingsAccount() { //Default Constructor
super();
}

public CheckingsAccount(double balance, int id) { //Constructor
super(balance,id);

}
//Methods

@Override
public void deposit(double amount) {
balance+=amount;
}
@Override   
public void withdraw(double amount) { // Can withdraw more than balance upto overdraftLimit
if(getBalance() + overdraftLimit < amount)
System.out.print("Amount exceeding overdraft limit. Please try again.");
else
balance-=amount;
}

@Override
public double getBalance(){
return balance;
}

@Override
public int getId(){
return accountId;
}
  
}

/*************BankingSystem.java***************/

import java.util.Scanner;
import java.util.Date;
import java.util.ArrayList;

public class BankingSystem {

public static void main(String[] args) {
//Create Scanner
Scanner input = new Scanner(System.in);
  
//Initialize all Variables
int choice;
int numberOfCustomers = 0;
int numberOfSavings = 0;
int numberOfCheckings=0;
boolean endProgram = false;
double amount;
  
//Create Arraylist for objects
ArrayList<SavingsAccount> acc= new ArrayList<>();
ArrayList<CheckingsAccount> cacc= new ArrayList<>();
ArrayList<Customer> cus = new ArrayList<>();
  
//Create Dummy accounts
Date date = new Date(2016,8,8);
acc.add(new SavingsAccount(1000,numberOfSavings,date));
numberOfSavings++;
cacc.add(new CheckingsAccount(1000,numberOfCheckings));
numberOfCheckings++;
cus.add(new Customer("John", "Doe", "4691234567",0, acc.get(0)));
numberOfCustomers++;
  
date =new Date(2012,01,01);
acc.add(new SavingsAccount(2000,numberOfSavings,date));
numberOfSavings++;
cacc.add(new CheckingsAccount(2000,numberOfCheckings));
numberOfCheckings++;
cus.add(new Customer("Johnny", "Doe", "4691234568",1, acc.get(1)));
numberOfCustomers++;
  
date =new Date(2016,01,01);
acc.add(new SavingsAccount(3000,numberOfSavings,date));
numberOfSavings++;
cacc.add(new CheckingsAccount(3000,numberOfCheckings));
numberOfCheckings++;
cus.add(new Customer("Johnathon", "Doe", "4691234567",2, acc.get(2)));
numberOfCustomers++;

//Menu Implementation
do{
int index;
System.out.println("1.Existing Client 2.New Client 3.Bank Manager 4.Quit ");
choice= input.nextInt();
switch(choice){
case 1:
System.out.println("What type of account do you have? 1.Savings 2.Checkings");
int type= input.nextInt();
if (type==1){
  
System.out.println("Enter your account number:");
index= input.nextInt();
System.out.println("What would you like to do: "
+ "1.Withdraw 2.Deposit 3.Create new Checkings Account 4.View "
+ "Account Summary 5.Quit ");
int choice1= input.nextInt();
switch (choice1){
case 1:
System.out.println("How much?");
amount=input.nextDouble();
acc.get(index).withdraw(amount);
break;
  
case 2:
System.out.println("How much?");
amount=input.nextDouble();
acc.get(index).deposit(amount);
break;

case 3:
System.out.print("Enter amount to deposit: ");
amount = input.nextDouble();
numberOfCheckings++;
cacc.add(numberOfCheckings,new CheckingsAccount(amount,numberOfCheckings));
System.out.println("Congratulations! You just made a Checkings Account! Your "
+ "new Account number is :"+ numberOfCheckings);
break;
  
case 4:
System.out.println("Name: "+cus.get(index).getName());
System.out.println( "Customer id: "+ cus.get(index).getId());
System.out.println();
if (acc.get(index)!=null)
{
System.out.println( "Account id: "+ acc.get(index).getId());
System.out.println( "Balance in savings: "+ acc.get(index).getBalance());
System.out.println("Account Creation Date: "+acc.get(index).getDateCreated());
}
if (cacc.get(index)!=null){
System.out.println( "Account id: "+ cacc.get(index).getId());
System.out.println("Balance in checking: "+ cacc.get(index).getBalance());
}
break;

case 5:
endProgram = true;
break;
  
default:
System.out.println("Invalid input please try again later.");
break;
  
}
}
if (type==2){

System.out.println("Enter your account number:");
index= input.nextInt();
System.out.println("What would you like to do: "
+ "1.Withdraw 2.Deposit 3.Create new Savings Account 4.View"
+ " Account Summary 5.Quit ");
int choice1= input.nextInt();
switch (choice1){
case 1:
System.out.println("How much?");
amount=input.nextDouble();
cacc.get(index).withdraw(amount);
break;
  
case 2:
System.out.println("How much?");
amount=input.nextDouble();
cacc.get(index).deposit(amount);
break;
  
case 3:
date = new Date();
System.out.print("Enter amount to deposit: ");
amount = input.nextDouble();
numberOfSavings++;
acc.add(numberOfSavings, new SavingsAccount(amount,numberOfSavings,date));
System.out.println("Congratulations! You just made a Savings Account! Your "
+ "new Account number is :"+ numberOfSavings);
  
break;
  
case 4:
System.out.println("Name: "+cus.get(index).getName());
System.out.println( "Customer id: "+ cus.get(index).getId());
System.out.println();
if (acc.get(index)!=null){
System.out.println( "Account id: "+ acc.get(index).getId());
System.out.println( "Balance in savings: "+ acc.get(index).getBalance());
System.out.println("Account Creation Date: "+acc.get(index).getDateCreated());
}
if (cacc.get(index)!=null){
System.out.println( "Account id: "+ cacc.get(index).getId());
System.out.println("Balance in checking: "+ cacc.get(index).getBalance());
}
break;
  
case 5:
endProgram = true;
break;
  
default:
System.out.println("Invalid input please try again later.");
break;

}
}
break;
case 2:
System.out.print("First name: ");
String firstName = input.next();
System.out.print("Last name: ");
String lastName = input.next();
System.out.print("Customer phone number: ");
String pnumber = input.next();

System.out.print("What kind of account would you like to make? 1.Savings 2.Checking");
int i= input.nextInt();
System.out.print("Enter amount to deposit: ");
amount = input.nextDouble();
System.out.println("Customer number is: " + numberOfCustomers);
if (i==1){
date = new Date();
acc.add(numberOfSavings, new SavingsAccount(amount,numberOfSavings,date));
cus.add(numberOfCustomers, new Customer(firstName, lastName, pnumber,numberOfCustomers, acc.get(numberOfCustomers)));
  
System.out.println("Congratulations! You just made a Savings Account! Your "
+ "new Account number is :"+ numberOfSavings);
numberOfCustomers++;
  
numberOfSavings++;
}
else if (i==2){
cacc.add(numberOfSavings,new CheckingsAccount(amount,numberOfCheckings));
cus.add(numberOfCustomers, new Customer(firstName, lastName, pnumber,numberOfCustomers, cacc.get(numberOfCustomers)));
  
System.out.println("Congratulations! You just made a Checkings Account! Your "
+ "new Account number is :"+ numberOfCheckings);
numberOfCustomers++;
  
numberOfCheckings++;
}
break;
case 3:
System.out.println("What do you want to do? 1.All customers list 2.Specific customer details");
int choice2=input.nextInt();
switch(choice2){
case 1:
i=0;
for (Customer c: cus){
System.out.println("Customer #"+(i+1));
System.out.println("Name: "+ c.getName());
System.out.println("Phone: "+ c.getNumber());
System.out.println("Customer Id: "+ c.getId());
i=c.getId();
if(acc.get(i)!=null){
System.out.println("Savings Account Id: "+ acc.get(i).getId());
System.out.println("Savings Account Balance: "+ acc.get(i).getBalance());
}
if(cacc.get(i)!=null){
System.out.println("Checkings Account Id: "+ cacc.get(i).getId());
System.out.println("Checkings Account Balance: "+ cacc.get(i).getBalance());

}
System.out.println(" ");
}
break;
  
case 2:
System.out.println("Please enter the Customer Id");
i=input.nextInt();
System.out.println("Customer #"+(i+1));
System.out.println("Name: "+ cus.get(i).getName());
System.out.println("Phone: "+ cus.get(i).getNumber());
System.out.println("Customer Id: "+ cus.get(i).getId());
if(acc.get(i)!=null){
System.out.println("Savings Account Id: "+ acc.get(i).getId());
System.out.println("Savings Account Balance: "+ acc.get(i).getBalance());
System.out.println("Account Creation Date: "+acc.get(i).getDateCreated());
  
}
if(cacc.get(i)!=null){
System.out.println("Checkings Account Id: "+ cacc.get(i).getId());
System.out.println("Checkings Account Balance: "+ cacc.get(i).getBalance());
}
break;
}
break;
case 4:
endProgram=true;
}
  
}while(!endProgram);

}
}

Explanation / Answer

Do you want the direction or you want the full UML diagram of the code. I can prepare the UML diagram & give you the link to that UML diagram(in the comment) so that you can download from there.

please let me know :)

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