Browse Source

mostly done.

William Simkins 8 years ago
parent
commit
7855756bba
2 changed files with 75 additions and 54 deletions
  1. 20
    27
      .idea/workspace.xml
  2. 55
    27
      src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java

+ 20
- 27
.idea/workspace.xml View File

@@ -2,14 +2,7 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="268ab437-e0d5-4447-8401-9f321aad6d50" name="Default" comment="">
5
-      <change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
6
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
7
-      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
8
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/Account.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/Account.java" afterDir="false" />
9 5
       <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java" afterDir="false" />
10
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/BusinessAccount.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/BusinessAccount.java" afterDir="false" />
11
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/CheckingAccount.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/CheckingAccount.java" afterDir="false" />
12
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/SavingsAccount.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/SavingsAccount.java" afterDir="false" />
13 6
     </list>
14 7
     <ignored path="$PROJECT_DIR$/out/" />
15 8
     <ignored path="$PROJECT_DIR$/target/" />
@@ -25,8 +18,8 @@
25 18
       <file leaf-file-name="BankAccount.java" pinned="false" current-in-tab="true">
26 19
         <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java">
27 20
           <provider selected="true" editor-type-id="text-editor">
28
-            <state relative-caret-position="250">
29
-              <caret line="26" column="147" selection-start-line="26" selection-start-column="147" selection-end-line="26" selection-end-column="147" />
21
+            <state relative-caret-position="291">
22
+              <caret line="28" column="170" selection-start-line="28" selection-start-column="170" selection-end-line="28" selection-end-column="170" />
30 23
             </state>
31 24
           </provider>
32 25
         </entry>
@@ -145,8 +138,8 @@
145 138
       <file leaf-file-name="CheckingAccountTest.java" pinned="false" current-in-tab="false">
146 139
         <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/bankaccountlab/CheckingAccountTest.java">
147 140
           <provider selected="true" editor-type-id="text-editor">
148
-            <state relative-caret-position="120">
149
-              <caret line="8" column="2" lean-forward="true" selection-start-line="8" selection-start-column="2" selection-end-line="84" selection-end-column="5" />
141
+            <state relative-caret-position="345">
142
+              <caret line="23" lean-forward="true" selection-start-line="23" selection-end-line="23" />
150 143
               <folding>
151 144
                 <element signature="imports" expanded="true" />
152 145
               </folding>
@@ -545,7 +538,7 @@
545 538
       <updated>1515620835041</updated>
546 539
       <workItem from="1528839645339" duration="5064000" />
547 540
       <workItem from="1529265876755" duration="1341000" />
548
-      <workItem from="1529409320058" duration="10855000" />
541
+      <workItem from="1529409320058" duration="14431000" />
549 542
     </task>
550 543
     <servers />
551 544
   </component>
@@ -582,7 +575,7 @@
582 575
     </history-entry>
583 576
   </component>
584 577
   <component name="TimeTrackingManager">
585
-    <option name="totallyTimeSpent" value="17260000" />
578
+    <option name="totallyTimeSpent" value="20836000" />
586 579
   </component>
587 580
   <component name="ToolWindowManager">
588 581
     <frame x="0" y="25" width="1280" height="722" extended-state="0" />
@@ -598,11 +591,11 @@
598 591
       <window_info anchor="right" id="Maven Projects" order="3" />
599 592
       <window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
600 593
       <window_info anchor="bottom" id="Version Control" order="7" />
601
-      <window_info anchor="bottom" id="Run" order="2" weight="0.3296" />
594
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.3296" />
602 595
       <window_info anchor="bottom" id="Terminal" order="7" weight="0.3287037" />
603 596
       <window_info id="Capture Tool" order="2" />
604 597
       <window_info id="Designer" order="2" />
605
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.26171243" />
598
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.26171243" />
606 599
       <window_info anchor="right" id="Database" order="4" />
607 600
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
608 601
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
@@ -954,16 +947,6 @@
954 947
         </state>
955 948
       </provider>
956 949
     </entry>
957
-    <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/bankaccountlab/CheckingAccountTest.java">
958
-      <provider selected="true" editor-type-id="text-editor">
959
-        <state relative-caret-position="120">
960
-          <caret line="8" column="2" lean-forward="true" selection-start-line="8" selection-start-column="2" selection-end-line="84" selection-end-column="5" />
961
-          <folding>
962
-            <element signature="imports" expanded="true" />
963
-          </folding>
964
-        </state>
965
-      </provider>
966
-    </entry>
967 950
     <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/bankaccountlab/SavingsAccountTest.java">
968 951
       <provider selected="true" editor-type-id="text-editor">
969 952
         <state relative-caret-position="255">
@@ -1066,10 +1049,20 @@
1066 1049
         </state>
1067 1050
       </provider>
1068 1051
     </entry>
1052
+    <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/bankaccountlab/CheckingAccountTest.java">
1053
+      <provider selected="true" editor-type-id="text-editor">
1054
+        <state relative-caret-position="345">
1055
+          <caret line="23" lean-forward="true" selection-start-line="23" selection-end-line="23" />
1056
+          <folding>
1057
+            <element signature="imports" expanded="true" />
1058
+          </folding>
1059
+        </state>
1060
+      </provider>
1061
+    </entry>
1069 1062
     <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java">
1070 1063
       <provider selected="true" editor-type-id="text-editor">
1071
-        <state relative-caret-position="250">
1072
-          <caret line="26" column="147" selection-start-line="26" selection-start-column="147" selection-end-line="26" selection-end-column="147" />
1064
+        <state relative-caret-position="291">
1065
+          <caret line="28" column="170" selection-start-line="28" selection-start-column="170" selection-end-line="28" selection-end-column="170" />
1073 1066
         </state>
1074 1067
       </provider>
1075 1068
     </entry>

+ 55
- 27
src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java View File

@@ -10,47 +10,75 @@ public class BankAccount {
10 10
     double amountToWithdraw;
11 11
     double currentAmount;
12 12
     double amountToDeposit;
13
+    boolean isRunning = true;
13 14
 
14
-    public BankAccount(){
15
+    public BankAccount() {
15 16
         this.amountToWithdraw = amountToWithdraw;
16
-        this.currentAmount = currentAmount;
17
+        this.currentAmount = 4000;
17 18
         this.amountToDeposit = amountToDeposit;
18 19
     }
19 20
 
20
-    public static void main(String[] args){
21
+    public static void main(String[] args) {
21 22
         BankAccount bank = new BankAccount();
22 23
         bank.start();
23 24
     }
24 25
 
25
-    public void start(){
26
-        Console.print("Welcome to Tyler's ATM");
27
-        String whichBankAccount = Console.stringPrompt("What bank account are you accessing today? Select either checking, Savings, or Business.");
28
-        if(whichBankAccount.equalsIgnoreCase("business")){
29
-            chooseAction();
30
-            ba.withdraw(currentAmount, amountToWithdraw);
31
-            ba.deposit(currentAmount, amountToDeposit);
32
-        } else if(whichBankAccount.equalsIgnoreCase("checking")){
33
-            chooseAction();
34
-            ca.withdraw(currentAmount, amountToWithdraw);
35
-            ca.deposit(currentAmount, amountToDeposit);
36
-        } else if(whichBankAccount.equalsIgnoreCase("savings")){
37
-            chooseAction();
38
-            sa.withdraw(currentAmount, amountToWithdraw);
39
-            sa.deposit(currentAmount, amountToDeposit);
40
-        } else {
41
-            Console.print("Please select an option from the list.");
42
-        }
26
+    public void start() {
27
+       do {
28
+            Console.print("Welcome to Tyler's ATM");
29
+            String whichBankAccount = Console.stringPrompt("What bank account are you accessing today? Select either checking, Savings, or Business. Or type exit to exit.");
30
+            if (whichBankAccount.equalsIgnoreCase("business")) {
31
+                chooseBusinessAccount();
32
+            } else if (whichBankAccount.equalsIgnoreCase("checking")) {
33
+                chooseCheckingAccount();
34
+            } else if (whichBankAccount.equalsIgnoreCase("savings")) {
35
+                chooseSavingsAccount();
36
+            } else {
37
+                Console.print("Please select an option from the list.");
38
+            }
39
+
40
+            if(whichBankAccount.equalsIgnoreCase("exit")){
41
+                isRunning = false;
42
+            }
43
+        } while(isRunning);
44
+
43 45
     }
44 46
 
45
-    public void chooseAction(){
46
-        Console.stringPrompt("Please choose either withdraw or deposit.");
47
-        String withdrawOrDeposit = Console.scanString();
48
-        if(withdrawOrDeposit.equalsIgnoreCase("withdraw")){
47
+    public void chooseAction() {
48
+        String withdrawOrDeposit = Console.stringPrompt("Please choose either withdraw or deposit.");
49
+        if (withdrawOrDeposit.equalsIgnoreCase("withdraw")) {
49 50
             double amountToWithdraw = Console.doublePrompt("How much money would you like to withdraw today?");
50
-        } else if(withdrawOrDeposit.equalsIgnoreCase("deposit")){
51
+            Console.print("You now have $" + (currentAmount - amountToWithdraw) + " in your bank account");
52
+        } else if (withdrawOrDeposit.equalsIgnoreCase("deposit")) {
51 53
             double amountToDeposit = Console.doublePrompt("How much money would you like to deposit today?");
54
+            Console.print("You now have $" + (currentAmount + amountToWithdraw) + " in your bank account");
52 55
         } else {
53 56
             Console.print("Please choose an option from the list.");
54 57
         }
55 58
     }
56
-}
59
+
60
+    public void chooseBusinessAccount(){
61
+        Console.doublePrompt("Please enter your pin number");
62
+        Console.print("Your current balance is: $" + currentAmount);
63
+        chooseAction();
64
+        ba.withdraw(currentAmount, amountToWithdraw);
65
+        ba.deposit(currentAmount, amountToDeposit);
66
+    }
67
+
68
+    public void chooseSavingsAccount(){
69
+        Console.doublePrompt("Please enter your pin number");
70
+        Console.print("Your current balance is: $" + currentAmount);
71
+        chooseAction();
72
+        ca.withdraw(currentAmount, amountToWithdraw);
73
+        ca.deposit(currentAmount, amountToDeposit);
74
+    }
75
+
76
+    public void chooseCheckingAccount(){
77
+        Console.doublePrompt("Please enter your pin number");
78
+        Console.print("Your current balance is: $" + currentAmount);
79
+        chooseAction();
80
+        sa.withdraw(currentAmount, amountToWithdraw);
81
+        sa.deposit(currentAmount, amountToDeposit);
82
+    }
83
+
84
+}