Skip to content

Monali2 #40

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 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d170664
Initial commit: setting up User class
Mar 13, 2021
f19ec33
fleshed out constructors and defined method signatures. method bodies…
Mar 13, 2021
f957aad
added method test signature definitions to UserTest class
KellyPorter02 Mar 13, 2021
a84a8dd
checkpointing - some method bodies complete, all test method signatur…
KellyPorter02 Mar 13, 2021
49509a7
all method bodies of User class complete
KellyPorter02 Mar 13, 2021
95b0229
checkpointing: test class skeleton almost complete, need to write tes…
KellyPorter02 Mar 13, 2021
0afe802
fixed some syntax errors in the User test class
KellyPorter02 Mar 13, 2021
677b912
Merge branch 'kellyBranch'
KellyPorter02 Mar 13, 2021
ece70e7
attempting to push User class skeleton
KellyPorter02 Mar 13, 2021
0e5b48a
added two classes ATM and Account and deleted main
Monali-Khandelwal Mar 14, 2021
b579cf1
Created login/logout, create new account, welcome menu, & console
theresa-christina Mar 14, 2021
bdd4533
Made some small changes
theresa-christina Mar 14, 2021
3c9973e
Merge pull request #2 from theresa-mashura/theresa
theresa-christina Mar 14, 2021
5c4a99b
adding some more changes
Monali-Khandelwal Mar 14, 2021
15a7ea0
merging changes from master and my local
Monali-Khandelwal Mar 14, 2021
d0a4940
Merge pull request #3 from theresa-mashura/Monali2
theresa-christina Mar 14, 2021
84f3bb9
Worked on merging together our code
theresa-christina Mar 14, 2021
bf05f8c
Merge pull request #4 from theresa-mashura/theresa
theresa-christina Mar 14, 2021
727741c
Added ability to close account & switch between accounts w/o losing d…
theresa-christina Mar 14, 2021
e2f6b38
Some small changes
theresa-christina Mar 14, 2021
782063d
Some minor changes
theresa-christina Mar 14, 2021
b4b45ed
Merge pull request #5 from theresa-mashura/theresa
theresa-christina Mar 14, 2021
0bed77d
Contructor tests for Account class
KellyPorter02 Mar 14, 2021
2ba38b1
merged
KellyPorter02 Mar 14, 2021
e146eb7
Merge pull request #7 from theresa-mashura/kellyBranch
theresa-christina Mar 14, 2021
98d4eb8
initial commit after latest pull from remote master
KellyPorter02 Mar 15, 2021
8256316
checkpointing: BankAccount class method tests 60% complete
KellyPorter02 Mar 15, 2021
1759214
Added unit tests for UserManagement class
theresa-christina Mar 15, 2021
5b91ec2
tests for BankAccount complete
KellyPorter02 Mar 15, 2021
f10f805
Added some UserAccount unit tests
theresa-christina Mar 15, 2021
c304189
Merge pull request #8 from theresa-mashura/theresa
theresa-christina Mar 15, 2021
d5eb193
Merge branch 'master' into kellyBranch
theresa-christina Mar 15, 2021
3af3e0c
Merge pull request #9 from theresa-mashura/kellyBranch
theresa-christina Mar 15, 2021
1665f32
Update BankAccountTest.java
theresa-christina Mar 15, 2021
002de75
Latest changes
Monali-Khandelwal Mar 15, 2021
2d706d2
removing merge conflicts
Monali-Khandelwal Mar 15, 2021
b598f8d
A couple small changes to tests
theresa-christina Mar 15, 2021
44c4534
Merge pull request #10 from theresa-mashura/theresa
theresa-christina Mar 15, 2021
fa85d22
Fix a typo
theresa-christina Mar 15, 2021
af305ec
Merge pull request #11 from theresa-mashura/theresa
theresa-christina Mar 15, 2021
b533b38
changes to recipt display
Monali-Khandelwal Mar 15, 2021
f7e2051
fixed the merge conflicts after pull origin master
Monali-Khandelwal Mar 15, 2021
34696ba
Merge pull request #12 from theresa-mashura/Monali2
theresa-christina Mar 15, 2021
37cbace
Minor changes
theresa-christina Mar 15, 2021
aa507b1
Merge pull request #13 from theresa-mashura/theresa
theresa-christina Mar 15, 2021
93f329e
Deleted the non working tests
Monali-Khandelwal Mar 15, 2021
83b476c
Final changes
Monali-Khandelwal 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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# project-2-ATM
Week 2 project: ATM Simulator
# project-2-Menu
Week 2 project: Menu Simulator

## ATM Requirements
## Menu Requirements

Every feature must have corresponding unit tests
Tests should demonstrate proper behavior, and proper handling of misuse (eg. attempts to deposit/transfer/withdraw negative amounts

- User interface: CLI (Command line interface) Only
- UserAccount interface: CLI (Command line interface) Only
- Direct Input
- Numbered options (instead of on-screen buttons)
- ASCII art welcome but not required
- Must support account types:
- Checking
- Savings
- Investment
- Account Actions
- BankAccount Actions
- Withdraw from acct
- Deposit to acct
- Transfer across accounts (self)
Expand Down
79 changes: 78 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,85 @@
<modelVersion>4.0.0</modelVersion>

<groupId>io.zipcoder</groupId>
<artifactId>project-2-atm</artifactId>
<artifactId>project-2-menu</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<<<<<<< HEAD
=======
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
>>>>>>> af305ec406a1dd384cd44f62166ca43f3c4e159f
</dependencies>


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

import java.text.NumberFormat;

public class AccountTrans {

private NumberFormat formatter;
private Console c;

public AccountTrans() {
this.c = new Console();
this.formatter = NumberFormat.getCurrencyInstance();
}

public void depositMoney(BankAccount chosenBankAccount) {
// Keeps track of which account to deposit money to - checking or saving
System.out.println("\nYour current " + chosenBankAccount.getAccountType() + " balance is: " + formatter.format(chosenBankAccount.getBalance()) + "\n");
System.out.println("How much money would you like to deposit?");

Double deposit;
deposit = c.getDoubleInput();
if (deposit < 0) {
System.out.println("Please enter amount greater than ZERO");
} else {
chosenBankAccount.deposit(deposit);
System.out.println("\nYour " + chosenBankAccount.getAccountType() + " balance is now: " + formatter.format(chosenBankAccount.getBalance()) + "\n");
chosenBankAccount.printTxn(chosenBankAccount.getAccountType() + " Deposit ", deposit, chosenBankAccount.getBalance());
System.out.println();
}
}

public void withdrawMoney(BankAccount chosenBankAccount) {

System.out.println("\nYour current " + chosenBankAccount.getAccountType() + " balance is: " + formatter.format(chosenBankAccount.getBalance()) + "\n");
System.out.println("How much money would you like to withdraw?");

Double withdraw;
withdraw = c.getDoubleInput();
if (withdraw > chosenBankAccount.getBalance()) {
System.out.println("INSUFFICIENT BALANCE! Your request will not be processed. \n");
} else {
chosenBankAccount.withdraw(withdraw);
System.out.println("\nYour " + chosenBankAccount.getAccountType() + " balance is now: " + formatter.format(chosenBankAccount.getBalance()) + "\n");
chosenBankAccount.printTxn(chosenBankAccount.getAccountType() + " withdraw ", withdraw, chosenBankAccount.getBalance() );
System.out.println();
}
}

public void transferMoney(BankAccount chosenTransferFromAccount, BankAccount chosenTransferToAccount) {
System.out.println("\nYour current " + chosenTransferFromAccount.getAccountType() + " balance is: " + formatter.format(chosenTransferFromAccount.getBalance()) + "\n");
System.out.print("How much money do you wish to transfer from " + chosenTransferFromAccount.getAccountType() + " to " + chosenTransferToAccount.getAccountType() + "?: ");

Double tranAmount;
tranAmount = c.getDoubleInput();
if (tranAmount > chosenTransferFromAccount.getBalance()) {
System.out.println("INSUFFICIENT BALANCE! " + "Please enter a new amount.");
} else {
chosenTransferFromAccount.withdraw(tranAmount);
chosenTransferToAccount.deposit(tranAmount);

System.out.println("\nYou successfully transferred " + formatter.format(tranAmount) + " from " + chosenTransferFromAccount.getAccountType() + " to " + chosenTransferToAccount.getAccountType());
System.out.println("\n" + chosenTransferFromAccount.getAccountType() + " Balance: " + formatter.format(chosenTransferFromAccount.getBalance()));
System.out.println(chosenTransferToAccount.getAccountType() + " Balance: " + formatter.format(chosenTransferToAccount.getBalance()) + "\n");
}
}

public void checkBalance (UserAccount currentUser) {
System.out.println("\nChecking Balance: " + formatter.format(currentUser.getCheckingAccount().getBalance()));
System.out.println("Savings Balance: " + formatter.format(currentUser.getSavingsAccount().getBalance()));
System.out.println("Investment Balance: " + formatter.format(currentUser.getInvestmentAccount().getBalance()) + "\n");
}


}


67 changes: 67 additions & 0 deletions src/main/java/BankAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import java.text.NumberFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;



public class BankAccount {


public String accountType;
private double currentBalance;
NumberFormat formatter = NumberFormat.getCurrencyInstance();


public BankAccount(String chosenAccountType) {
this.accountType = chosenAccountType;
this.currentBalance = 0;
}


void setType(String accType) {
accountType = accType;
}

void setBalance(Double accBal) {
currentBalance = accBal;
}

public String getAccountType() {
return this.accountType;
}

Double getBalance() {
return currentBalance;
}

void deposit(Double dep) {
currentBalance = currentBalance + dep;
}

void withdraw(Double wit) {
currentBalance = currentBalance - wit;
}

void printTxn(String txnType, Double amt, Double balance){


System.out.println("|---------------------------------------------------------");
System.out.println("| BANK OF ZIP CODE WILMINGTON DE ");
System.out.println("|---------------------------------------------------------");
System.out.println("|" + dateTime() + " ");
System.out.println("|---------------------------------------------------------");
System.out.println("| Transaction Receipt ");
System.out.println("|" + txnType + " ");
System.out.println("|" + amt + "" + " ");
System.out.println("|Remaining Balance: " + balance + " ");
System.out.println("|---------------------------------------------------------");

}
String dateTime(){

DateTimeFormatter timeFormat = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();

return timeFormat.format(now);
}
}
35 changes: 35 additions & 0 deletions src/main/java/Console.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import java.util.Scanner;

public class Console {

public String getStringInput() {
Scanner scanner = new Scanner(System.in);
String userInput = scanner.nextLine();
if (userInput.isEmpty()) {
System.out.println("Invalid Input!");
userInput = scanner.nextLine();
}
return userInput;
}

public Integer getIntegerInput() {
Scanner scanner = new Scanner(System.in);
while(!scanner.hasNextInt()) {
System.out.println("Invalid Input!");
scanner.next();
}
int userInput = scanner.nextInt();
return userInput;
}

public Double getDoubleInput() {
Scanner scanner = new Scanner(System.in);
while(!scanner.hasNextDouble()) {
System.out.println("Invalid Input!");
scanner.next();
}
double userInput = scanner.nextDouble();
return userInput;
}

}
3 changes: 2 additions & 1 deletion src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
public class Main {

public static void main(String[] args){

Menu menu = new Menu();
menu.printMenus();
}
}
Loading