William Simkins před 8 roky
rodič
revize
7855756bba

+ 20
- 27
.idea/workspace.xml Zobrazit soubor

2
 <project version="4">
2
 <project version="4">
3
   <component name="ChangeListManager">
3
   <component name="ChangeListManager">
4
     <list default="true" id="268ab437-e0d5-4447-8401-9f321aad6d50" name="Default" comment="">
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
       <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" />
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
     </list>
6
     </list>
14
     <ignored path="$PROJECT_DIR$/out/" />
7
     <ignored path="$PROJECT_DIR$/out/" />
15
     <ignored path="$PROJECT_DIR$/target/" />
8
     <ignored path="$PROJECT_DIR$/target/" />
25
       <file leaf-file-name="BankAccount.java" pinned="false" current-in-tab="true">
18
       <file leaf-file-name="BankAccount.java" pinned="false" current-in-tab="true">
26
         <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java">
19
         <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java">
27
           <provider selected="true" editor-type-id="text-editor">
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
             </state>
23
             </state>
31
           </provider>
24
           </provider>
32
         </entry>
25
         </entry>
145
       <file leaf-file-name="CheckingAccountTest.java" pinned="false" current-in-tab="false">
138
       <file leaf-file-name="CheckingAccountTest.java" pinned="false" current-in-tab="false">
146
         <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/bankaccountlab/CheckingAccountTest.java">
139
         <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/bankaccountlab/CheckingAccountTest.java">
147
           <provider selected="true" editor-type-id="text-editor">
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
               <folding>
143
               <folding>
151
                 <element signature="imports" expanded="true" />
144
                 <element signature="imports" expanded="true" />
152
               </folding>
145
               </folding>
545
       <updated>1515620835041</updated>
538
       <updated>1515620835041</updated>
546
       <workItem from="1528839645339" duration="5064000" />
539
       <workItem from="1528839645339" duration="5064000" />
547
       <workItem from="1529265876755" duration="1341000" />
540
       <workItem from="1529265876755" duration="1341000" />
548
-      <workItem from="1529409320058" duration="10855000" />
541
+      <workItem from="1529409320058" duration="14431000" />
549
     </task>
542
     </task>
550
     <servers />
543
     <servers />
551
   </component>
544
   </component>
582
     </history-entry>
575
     </history-entry>
583
   </component>
576
   </component>
584
   <component name="TimeTrackingManager">
577
   <component name="TimeTrackingManager">
585
-    <option name="totallyTimeSpent" value="17260000" />
578
+    <option name="totallyTimeSpent" value="20836000" />
586
   </component>
579
   </component>
587
   <component name="ToolWindowManager">
580
   <component name="ToolWindowManager">
588
     <frame x="0" y="25" width="1280" height="722" extended-state="0" />
581
     <frame x="0" y="25" width="1280" height="722" extended-state="0" />
598
       <window_info anchor="right" id="Maven Projects" order="3" />
591
       <window_info anchor="right" id="Maven Projects" order="3" />
599
       <window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
592
       <window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
600
       <window_info anchor="bottom" id="Version Control" order="7" />
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
       <window_info anchor="bottom" id="Terminal" order="7" weight="0.3287037" />
595
       <window_info anchor="bottom" id="Terminal" order="7" weight="0.3287037" />
603
       <window_info id="Capture Tool" order="2" />
596
       <window_info id="Capture Tool" order="2" />
604
       <window_info id="Designer" order="2" />
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
       <window_info anchor="right" id="Database" order="4" />
599
       <window_info anchor="right" id="Database" order="4" />
607
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
600
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
608
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
601
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
954
         </state>
947
         </state>
955
       </provider>
948
       </provider>
956
     </entry>
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
     <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/bankaccountlab/SavingsAccountTest.java">
950
     <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/bankaccountlab/SavingsAccountTest.java">
968
       <provider selected="true" editor-type-id="text-editor">
951
       <provider selected="true" editor-type-id="text-editor">
969
         <state relative-caret-position="255">
952
         <state relative-caret-position="255">
1066
         </state>
1049
         </state>
1067
       </provider>
1050
       </provider>
1068
     </entry>
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
     <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java">
1062
     <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java">
1070
       <provider selected="true" editor-type-id="text-editor">
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
         </state>
1066
         </state>
1074
       </provider>
1067
       </provider>
1075
     </entry>
1068
     </entry>

+ 55
- 27
src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java Zobrazit soubor

10
     double amountToWithdraw;
10
     double amountToWithdraw;
11
     double currentAmount;
11
     double currentAmount;
12
     double amountToDeposit;
12
     double amountToDeposit;
13
+    boolean isRunning = true;
13
 
14
 
14
-    public BankAccount(){
15
+    public BankAccount() {
15
         this.amountToWithdraw = amountToWithdraw;
16
         this.amountToWithdraw = amountToWithdraw;
16
-        this.currentAmount = currentAmount;
17
+        this.currentAmount = 4000;
17
         this.amountToDeposit = amountToDeposit;
18
         this.amountToDeposit = amountToDeposit;
18
     }
19
     }
19
 
20
 
20
-    public static void main(String[] args){
21
+    public static void main(String[] args) {
21
         BankAccount bank = new BankAccount();
22
         BankAccount bank = new BankAccount();
22
         bank.start();
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
             double amountToWithdraw = Console.doublePrompt("How much money would you like to withdraw today?");
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
             double amountToDeposit = Console.doublePrompt("How much money would you like to deposit today?");
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
         } else {
55
         } else {
53
             Console.print("Please choose an option from the list.");
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
+}