Skip to content

Project completed from team - Xiong, Mike, Hazel, and Lena #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9235634
Tentative UML finished
Mar 12, 2021
5a019b7
Merge pull request #1 from xyuan04/HazelBranch
xyuan04 Mar 12, 2021
889be64
Began Display/Console
Mar 12, 2021
890237e
created Account classes and wrote some tests
Mar 13, 2021
e41f6a3
Merge pull request #2 from xyuan04/XiongBranch
xyuan04 Mar 13, 2021
1719525
removed setBalance() and fixed deposit() + Unit Test
Mar 13, 2021
a13c9f6
Merge pull request #3 from xyuan04/XiongBranch
xyuan04 Mar 13, 2021
c89fda9
did Customer
Mar 13, 2021
e5d8c4f
Merge pull request #4 from xyuan04/MikesBranch
xyuan04 Mar 13, 2021
e229de1
More console code
Mar 13, 2021
9903397
Merge pull request #5 from xyuan04/HazelBranch
xyuan04 Mar 13, 2021
e28faf5
testInvestment done
CodeHere21 Mar 13, 2021
4e336e3
tests for SavingAccount
CodeHere21 Mar 13, 2021
9c0a4bb
almost done with test missing last one
Mar 13, 2021
1afca0a
updated test complete
Mar 13, 2021
2b31d93
Test complete
xyuan04 Mar 13, 2021
07f6fef
Merge pull request #7 from xyuan04/lenasbranch
xyuan04 Mar 13, 2021
6353206
moved methods for open/close to Customer class
Mar 13, 2021
dab953f
moved methods for open/close to Customer class
xyuan04 Mar 13, 2021
11dfb66
fixed and refactor code
Mar 14, 2021
c7a283c
fixed and refactor code
xyuan04 Mar 14, 2021
86a0e67
Minor refinement of display
Mar 13, 2021
f802066
Split display into another class, workflow
Mar 13, 2021
078fa02
More work on workflow
Mar 13, 2021
76ab0f9
Checkpointing
Mar 13, 2021
cc2f1a3
Checkpointing
Mar 13, 2021
219c957
Filled out workflow
Mar 13, 2021
621a083
Manual update
Mar 13, 2021
6abeec9
Checkpointing for pull. Began workflow test
Mar 14, 2021
7e0fbd5
Fighting git
Mar 14, 2021
9fe8146
Merge pull request #13 from xyuan04/HazelBranch
xyuan04 Mar 14, 2021
36861cb
merged progress
Mar 14, 2021
34f26f6
merged progress
xyuan04 Mar 14, 2021
d1acf68
Shell for engine written out
Mar 14, 2021
065a473
Shell for engine written out
xyuan04 Mar 14, 2021
b987b6e
fixed Console getInteger and getDouble
Mar 14, 2021
b3a5303
fixed Console getInteger and getDouble
xyuan04 Mar 14, 2021
9c5a9ed
Checkpointing
Mar 14, 2021
31b3604
Inserted enterAcctType
Mar 14, 2021
b3a0512
Merge remote-tracking branch 'origin/HazelBranch' into HazelBranch
Mar 14, 2021
bc0e4c8
Merge pull request #17 from xyuan04/HazelBranch
xyuan04 Mar 14, 2021
8a08377
created and tested Creator Class will finish Database later
xyuan04 Mar 14, 2021
afaaeb6
created and tested Database
xyuan04 Mar 14, 2021
600288b
* added methods in Customer and Database + tested
xyuan04 Mar 14, 2021
c3f1160
opening and closing account
CodeHere21 Mar 14, 2021
cccae94
added login menu and create customer
MNinh Mar 14, 2021
17a6e4d
updated main, account, database
xyuan04 Mar 14, 2021
16c4cba
finalized ATM
xyuan04 Mar 15, 2021
45e1d0c
added check account numbers for motherboard + minor fixes
xyuan04 Mar 15, 2021
66928d4
finalized ATM
MNinh Mar 15, 2021
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
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
<groupId>io.zipcoder</groupId>
<artifactId>project-2-atm</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>


</project>
31 changes: 31 additions & 0 deletions src/main/java/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
public abstract class Account {
private final Integer accountNumber;
private double balance;

protected Account(Integer accountNumber, double balance) {
this.accountNumber = accountNumber;
this.balance = balance;
}

public int getAccountNumber() {
return accountNumber;
}

public double getBalance() {
return balance;
}

public double withdraw(double amount) {
if (balance >= amount && amount >= 0) {
balance -= amount;
}
return balance;
}

public double deposit(double amount) {
if (amount > 0) {
return balance += amount;
} else return balance;
}

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

public Checking(Integer accountNumber, double balance) {
super(accountNumber,balance);
}

public void transferToSavings(Savings savingsAccount, double transferAmount) {
if (this.getBalance() >= transferAmount) {
this.withdraw(transferAmount);
savingsAccount.deposit(transferAmount);
}
}

public void transferToInvestment(Investment investmentAccount, double transferAmount) {
if (this.getBalance() >= transferAmount) {
this.withdraw(transferAmount);
investmentAccount.deposit(transferAmount);
}
}
}
51 changes: 51 additions & 0 deletions src/main/java/Console.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import java.util.Scanner;

public class Console {

public static void print(String output, Object... args) {
System.out.printf(output, args);
}

public static void println(String output, Object... args) {
print(output + "\n", args);
}

public String getStringInput(String prompt) {
Scanner scanner = new Scanner(System.in);
println(prompt);
String userInput = scanner.nextLine();
return userInput;
}

public String getStringInputNotCaseSensitive(String prompt) {
Scanner scanner = new Scanner(System.in);
println(prompt);
String userInput = scanner.nextLine();
return userInput.toLowerCase();
}

public Integer getIntegerInput(String prompt) {
Scanner scanner = new Scanner(System.in);
println(prompt);
while (!scanner.hasNextInt()) {
System.out.println("Input is not a number.");
scanner.nextLine();
}
int userInput = scanner.nextInt();
return userInput;

}

public Double getDoubleInput(String prompt) {
Scanner scanner = new Scanner(System.in);
println(prompt);
while (!scanner.hasNextDouble()) {
System.out.println("Input is not a number.");
scanner.nextLine();
}
Double userInput = scanner.nextDouble();
return userInput;

}

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

public static Customer createCustomer(String name, String userName, String password, Account... accounts) {
return new Customer(name, userName, password, accounts);
}

public static Checking createChecking(double initialDeposit) {
Integer newAccountNumber = (int)(Math.random() * ((999-100) + 1) + 100);
return new Checking(newAccountNumber, initialDeposit);
}

public static Savings createSavings(double initialDeposit) {
Integer newAccountNumber = (int)(Math.random() * ((9999-1000) + 1) + 1000);
return new Savings(newAccountNumber, initialDeposit);
}

public static Investment createInvestment(double initialDeposit) {
Integer newAccountNumber = (int)(Math.random() * ((99999-10000) + 1) + 10000);
return new Investment(newAccountNumber, initialDeposit);
}

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

public class Customer {
private String customerName;
private String userName;
private String password;
private ArrayList<Account> accounts = new ArrayList<Account>();


public Customer(String customerName, String userName, String password, Account... accounts) {
this.customerName = customerName;
this.userName = userName;
this.password = password;
if (accounts != null) {
this.accounts.addAll(Arrays.asList(accounts));
}
}

public String getCustomerName(){ return this.customerName;}

public void setCustomerName(String customerName){ this.customerName = customerName;}

public String getUserName(){
return this.userName;
}

public void setUserName(String userName){
this.userName = userName;
}

public String getPassword(){
return this.password;
}

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

public String getAccountNumber() {
String accountNumbers = "Accounts: \n";
for(int i = 0; i < accounts.size(); i++) {
accountNumbers += String.format("%d : %s\n", i+1, accounts.get(i).getAccountNumber());
}
return accountNumbers;
}

public Account getAccount(int accountNumber) {
for (Account account : accounts) {
if (account.getAccountNumber() == accountNumber) {
return account;
}
}
return null;
}

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

public int getNumberOfAccounts() {
return accounts.size();
}

public void closeAccount(Integer accountNumber) {
for (int i = 0; i < accounts.size(); i++) {
if (accounts.get(i).getAccountNumber() == accountNumber) {
if (accounts.get(i).getBalance() == 0) {
accounts.remove(i);
}
}
}
}
}
46 changes: 46 additions & 0 deletions src/main/java/Database.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import java.util.ArrayList;
import java.util.Arrays;

public class Database {
private static volatile ArrayList<Customer> currentCustomers = new ArrayList<Customer>();

public static void addCustomer(Customer customer) {
currentCustomers.add(customer);
}

public static void addMultipleCustomers(Customer... customer) {
currentCustomers.addAll(Arrays.asList(customer));
}

public static Customer getCustomerByName(String name) {
for(Customer customer : currentCustomers) {
if(customer.getCustomerName().equals(name)) {
return customer;
}
}
return null;
}

public static Customer getCustomerByUsername(String username) {
for(Customer customer : currentCustomers) {
if(customer.getUserName().equals(username)) {
return customer;
}
}
return null;
}

public static void removeCustomer(Customer customer) {
currentCustomers.remove(customer);
}

public static Integer getNumberOfCustomers() {
return currentCustomers.size();
}

public static void removeAllCustomers() {
currentCustomers.clear();
}


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

String currentDisplay;
String transactionHistory;

public Display(){
this.currentDisplay = "";
this.transactionHistory = "";
}

/* *****Getters and setters***** */

public void printCurrentDisplay() {
System.out.println(currentDisplay);
}

public void setCurrentDisplay(String currentDisplay) {
this.currentDisplay = currentDisplay;
}

//set AND print in one
public void currentDisplaySP(String currentDisplay){
this.setCurrentDisplay(currentDisplay);
this.printCurrentDisplay();
}



public void printTransactionHistory() {
System.out.println(transactionHistory);
}

public void setTransactionHistory(String transactionHistory) {
this.transactionHistory = transactionHistory;
}

public void addToTransactionHistory(String snippet){
this.transactionHistory = this.transactionHistory + snippet;
}


}









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

public Investment(Integer accountNumber, double balance) {
super(accountNumber, balance);
}

public void transferToSavings(Savings savingsAccount, double transferAmount) {
if (this.getBalance() >= transferAmount) {
this.withdraw(transferAmount);
savingsAccount.deposit(transferAmount);
}
}

public void transferToChecking(Checking checkingAccount, double transferAmount) {
if (this.getBalance() >= transferAmount) {
this.withdraw(transferAmount);
checkingAccount.deposit(transferAmount);
}
}
}
16 changes: 14 additions & 2 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,20 @@
* Created by iyasuwatts on 10/17/17.
*/
public class Main {
private boolean engineOn = true;

public static void main(String[] args){

public static void main(String[] args) {
Main main = new Main();
Motherboard ATM = new Motherboard();
Workflow screen = new Workflow();
Customer xiong = Creator.createCustomer("xiong", "xyuan", "zipcode", new Checking(100, 1500), new Savings(1000, 2500), new Investment(10000, 6000));
Customer mike = Creator.createCustomer("mike", "ninh", "zipcode", new Checking(101, 1500), new Savings(1001, 2500), new Investment(10001, 6000));
Customer hazel = Creator.createCustomer("hazel", "hbecker", "zipcode", new Checking(102, 1500), new Savings(1002, 2500), new Investment(10002, 6000));
Customer lena = Creator.createCustomer("lena", "llitouka", "zipcode", new Checking(103, 1500), new Savings(1003, 2500), new Investment(10003, 6000));
Database.addMultipleCustomers(xiong, mike, hazel, lena);

while (main.engineOn) {
ATM.runEngine(screen);
}
}
}
Loading