Skip to content

Commit 0ef8089

Browse files
donald fdonald f
authored andcommitted
it's not going to be pretty but I've refactored and refactored and now have some test
1 parent fbdedaf commit 0ef8089

File tree

17 files changed

+290
-40
lines changed

17 files changed

+290
-40
lines changed
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
package foutain.donald.atmproject.bettercopy.ATMFunctions;
22

3+
import foutain.donald.atmproject.bettercopy.UserFunctions.UserFactory;
4+
import foutain.donald.atmproject.bettercopy.UserFunctions.UserWarehouse;
5+
36
public class ATM {
47

5-
public int startATM(){
6-
int userInput = PromptUser.userStartATM();
7-
return userInput;
8+
public void startATM(int userInput){
9+
userInput = PromptUser.userStartATM();
10+
boolean terminator = true;
11+
while(terminator == true){
12+
if("1".equals(userInput)){
13+
// UserFactory.createNewUser();
14+
} else if("2".equals(userInput)){
15+
UserWarehouse.userLogin();
16+
} else {
17+
PromptUser.correctResponse();
18+
}
19+
}
820
}
921

10-
public static void userOption(){
11-
System.out.println("User Options are: ");
12-
}
1322
}

src/main/java/foutain/donald/atmproject/bettercopy/ATMFunctions/Main.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/main/java/foutain/donald/atmproject/bettercopy/ATMFunctions/PromptUser.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,15 @@ public static String getUserPassWord(){
1818
String userInfo = Console.getStringInput("Please enter your password.");
1919
return userInfo;
2020
}
21+
22+
public static int getUserAccountType(){
23+
int userInfo = Console.getIntInput("Account type options\n"+
24+
"1: Checking\n2: Savings\n 3: Investments");
25+
return userInfo;
26+
}
27+
28+
public static int correctResponse(){
29+
int userInfo = Console.getIntInput("Please reread the above directions and answer appropriately.");
30+
return userInfo;
31+
}
2132
}

src/main/java/foutain/donald/atmproject/bettercopy/AccountFunctions/Account.java

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,65 @@ public class Account {
1212

1313
private ArrayList<String> transactionHistory;
1414

15-
public double getAccountBalance(){
15+
//Getter and Setter for TypeOfAccount
1616

17-
return this.accountBalance;
17+
public String getTypeOfAccount() {
18+
return typeOfAccount;
1819
}
1920

20-
public double withdrawMoney(int withdrawAmount){
21+
public void setTypeOfAccount(String typeOfAccount) {
22+
this.typeOfAccount = typeOfAccount;
23+
}
2124

22-
this.accountBalance -= withdrawAmount;
25+
//Getter and Setter for AccountNumber
26+
27+
public int getAccountNumber() {
28+
return accountNumber;
29+
}
30+
31+
public void setAccountNumber(int accountNumber) {
32+
this.accountNumber = accountNumber;
33+
}
34+
35+
//Getter and Setter for AccountBalance
2336

37+
public double getAccountBalance() {
2438
return accountBalance;
2539
}
2640

41+
public void setAccountBalance(double accountBalance) {
42+
this.accountBalance = accountBalance;
43+
}
44+
45+
//Getter and Setter for TransactionHistory
46+
47+
public ArrayList<String> getTransactionHistory() {
48+
return transactionHistory;
49+
}
50+
51+
public void setTransactionHistory(ArrayList<String> transactionHistory) {
52+
this.transactionHistory = transactionHistory;
53+
}
54+
55+
//Methods for Accounts
56+
57+
public String withdrawMoney(double withdrawAmount){
58+
59+
this.accountBalance -= withdrawAmount;
60+
61+
return "Your new account balance is: " + accountBalance;
62+
}
63+
2764
public String closeAccount(){
2865

2966
return "Your account has been closed";
3067
}
3168

32-
public double depositMoney(int depositAmount){
69+
public String depositMoney(double depositAmount){
3370

3471
this.accountBalance += depositAmount;
3572

36-
return accountBalance;
73+
return "Your new account balance is: " + accountBalance;
3774
}
3875

3976
public ArrayList<String > printTransactionHistory(ArrayList<String> transactionHistory){
@@ -43,6 +80,6 @@ public ArrayList<String > printTransactionHistory(ArrayList<String> transactionH
4380

4481
public String openAccountType(){
4582

46-
return typeOfAccount;
83+
return "You have just opened a " + typeOfAccount;
4784
}
4885
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package foutain.donald.atmproject.bettercopy.AccountFunctions;
2+
3+
public class Checking {
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package foutain.donald.atmproject.bettercopy.AccountFunctions;
2+
3+
public class Investments {
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package foutain.donald.atmproject.bettercopy.AccountFunctions;
2+
3+
public class Saving {
4+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package foutain.donald.atmproject.bettercopy;
2+
3+
import foutain.donald.atmproject.bettercopy.ATMFunctions.ATM;
4+
5+
/**
6+
* Created by iyasuwatts on 10/17/17.
7+
*/
8+
public class Main {
9+
10+
public static void main(String[] args){
11+
//ATM newATM = new ATM();
12+
//newATM.startATM();
13+
14+
}
15+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package foutain.donald.atmproject.bettercopy.Tests;
2+
3+
import foutain.donald.atmproject.bettercopy.AccountFunctions.Account;
4+
import org.junit.Assert;
5+
import org.junit.Test;
6+
7+
public class AccountTests {
8+
9+
@Test
10+
public void getTypeOfAccountTest(){
11+
Account newAccount = new Account();
12+
String expected = "Checking";
13+
14+
String typeOfAccount = "Checking";
15+
newAccount.setTypeOfAccount(typeOfAccount);
16+
String actual = newAccount.getTypeOfAccount();
17+
18+
Assert.assertEquals(expected, actual);
19+
}
20+
21+
@Test
22+
public void getAccountNumber(){
23+
Account newAccount = new Account();
24+
int expected = 10000;
25+
26+
int accountNumber = 10000;
27+
newAccount.setAccountNumber(accountNumber);
28+
int actual = newAccount.getAccountNumber();
29+
30+
Assert.assertEquals(expected, accountNumber);
31+
}
32+
33+
@Test
34+
public void getAccountBalance(){
35+
Account newAccount = new Account();
36+
double expected = 100.55;
37+
38+
double accountBalance = 100.55;
39+
newAccount.setAccountBalance(accountBalance);
40+
double actual = newAccount.getAccountBalance();
41+
42+
Assert.assertEquals(expected, actual, 0);
43+
}
44+
45+
@Test
46+
public void withDrawMoneyTest(){
47+
Account newAccount = new Account();
48+
String expected = "Your new account balance is: 200.0";
49+
50+
double accountBalance = 260;
51+
double withDrawAmount = 60;
52+
newAccount.setAccountBalance(accountBalance);
53+
String actual = newAccount.withdrawMoney(withDrawAmount);
54+
55+
Assert.assertEquals(expected,actual);
56+
}
57+
58+
@Test
59+
public void depositMoneyTest(){
60+
Account newAccount = new Account();
61+
String expected = "Your new account balance is: 260.0";
62+
63+
double accountBalance = 200;
64+
double depositAmount = 60;
65+
newAccount.setAccountBalance(accountBalance);
66+
String actual = newAccount.depositMoney(depositAmount);
67+
68+
Assert.assertEquals(expected,actual);
69+
}
70+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package foutain.donald.atmproject.bettercopy.Tests;
2+
3+
public class CheckingTest {
4+
}

0 commit comments

Comments
 (0)