Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@
<artifactId>project-2-atm</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

</dependencies>

</project>
76 changes: 76 additions & 0 deletions src/main/java/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

public abstract class Account {

private int acctnumber;
private double balance;


public Account(){
this.acctnumber = AccountWarehouse.getAccounts().size();
this.balance = 0;
//nextAvailableAcctNumber++;
}

public Account(double initial_deposit){
this();
this.balance = initial_deposit;
}

public void setAcctNumber(int acctnumber) {
this.acctnumber = acctnumber;
}


public int getAcctNumber() {
return acctnumber;
}


public void setBalance(double balance) {
this.balance = balance;
}


public double getBalance() {
return balance;
}

public String deposit(double deposit) {

balance += deposit;

return "Your new balance is $" + String.format("%,.2f", balance);

}

public String withdrawl(double withdrawl){

balance -= withdrawl;

return "Your new balance is $" + String.format("%,.2f", balance);

}

public String transfer(Account toAccount, double amount){

balance -= amount;

toAccount.balance += amount;


return "Transfer complete. New 'from' balance is $" + String.format("%,.2f", this.getBalance()) + ". Your new 'to' balance is $" + String.format("%,.2f", toAccount.getBalance())+".";
}

// @Override
// public String toString(){
// return "Account# " + this.acctnumber;


}







35 changes: 35 additions & 0 deletions src/main/java/AccountWarehouse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import java.util.ArrayList;

public class AccountWarehouse {
private static final ArrayList<Account> accounts = new ArrayList<Account>();

private AccountWarehouse(){

}

public static ArrayList<Account> getAccounts() {
return accounts;
}

public static Account findAccountByAcctNumber(int acctNumber) {

for (int i = 0; i < accounts.size(); i++) {
if (accounts.get(i).getAcctNumber() == acctNumber) {
return accounts.get(i);
}
}return null;
}

public static void addAccount(Account account){
accounts.add(account);
}

public static void removeAccount(Account account){
accounts.remove(account);

}


}


10 changes: 10 additions & 0 deletions src/main/java/Checking.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class Checking extends Account {

public Checking(){
super();
}

public Checking(double initial_deposit){
super(initial_deposit);
}
}
120 changes: 120 additions & 0 deletions src/main/java/Customer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import java.util.ArrayList;

public class Customer {

private String username;
private String password;
private ArrayList<Account> customerAccounts;


public Customer(){
this.username = "UNASSIGNED";
this.password = "PASSWORD";
this.customerAccounts = new ArrayList<Account>();
this.customerAccounts.add(new Checking());
}


public Customer(String username){
this();
this.username = username;

}

public Customer(String username, String password){
this(username);
this.password = password;
}


public void setPassword(String password) {
this.password = password;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public String getUsername() {
return username;
}

public ArrayList<Account> getCustomerAccounts() {
return customerAccounts;
}

public void openAccount(){
Account checking = new Checking();
customerAccounts.add(checking);
AccountWarehouse.addAccount(checking);


}

public Account lookupAcctByNumber(int accountnumber){
for(int i = 0; i <customerAccounts.size(); i++){
if(customerAccounts.get(i).getAcctNumber() == accountnumber){}
return customerAccounts.get(i);
}
return null;
}




// public String getAccountByIndex(int index){
// return AccountList.get(index).toString();
//
// }
//
// public int getNumberOfAccounts(){
// return AccountList.size();
// }
//
// public Account getAccountObjectByIndex(int index){
// return AccountList.get(index);
// }
//
// public void addOneAccount(){
// this.AccountList.add(new Checking());
// return;
//
// }
//

// public String getAccountList() {
// for (:
// ) {
//
// }
// }

// public ArrayList<Account> getAccount(int index){
//
// return AccountList;
//
// };
//

//
// public void closeAllAccounts(){
//
// }






// public ArrayList[] getAccountList() {
// return AccountList;
// }




}
33 changes: 33 additions & 0 deletions src/main/java/CustomerWarehouse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.util.ArrayList;

public class CustomerWarehouse {

private static final ArrayList<Customer> customers = new ArrayList<Customer>();



public static ArrayList<Customer> getCustomers() {
return customers;
}

public static Customer lookupCustomer(String username) {
// for(Customer currentelement: customers) {
// if (customers.get(currentelement).getUsername() == username) {
// return customers.get(currentelement);
// }
// }
for (int i = 0; i < customers.size(); i++) {
if (customers.get(i).getUsername() == username) {
return customers.get(i);
}

}return null;
}
public static void addCustomer(Customer customer){
customers.add(customer);
}

public static void removeCustomer(Customer customer){
customers.remove(customer);
}
}
18 changes: 18 additions & 0 deletions src/main/java/DoTheThing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//public class DoTheThing {
//
// public static void main(String[] args) {
//
// System.out.println("Got an account with us? y/n");
// System.out.println("Want one? y/n");
//
// createUser();
// addtoAllTheUsers();
//
// System.out.println("What do you want to do with your account?");
//
// showMainMenu();
// // 1. Deposit 2. Withdraw 3. Get Balance 4. Add Account 5. Close Account
//
// }
//
//}
10 changes: 10 additions & 0 deletions src/main/java/Investment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class Investment extends Account {

public Investment(){
super();
}

public Investment(double initial_deposit){
super(initial_deposit);
}
}
2 changes: 1 addition & 1 deletion src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
public class Main {

public static void main(String[] args){

}
}
10 changes: 10 additions & 0 deletions src/main/java/Savings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class Savings extends Account {

public Savings(){
super();
}

public Savings(double initial_deposit){
super(initial_deposit);
}
}
Loading