Randall Gibson Jr 6 år sedan
förälder
incheckning
7c73d0118b

+ 1
- 0
.idea/.name Visa fil

@@ -0,0 +1 @@
1
+bankaccountlab

+ 1
- 1
.idea/compiler.xml Visa fil

@@ -9,7 +9,7 @@
9 9
         <module name="bankaccountlab" />
10 10
       </profile>
11 11
     </annotationProcessing>
12
-    <bytecodeTargetLevel target="1.8">
12
+    <bytecodeTargetLevel>
13 13
       <module name="bankaccountlab" target="1.5" />
14 14
     </bytecodeTargetLevel>
15 15
   </component>

+ 13
- 0
.idea/libraries/Maven__junit_junit_4_12.xml Visa fil

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: junit:junit:4.12">
3
+    <CLASSES>
4
+      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml Visa fil

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: org.hamcrest:hamcrest-core:1.3">
3
+    <CLASSES>
4
+      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 1
- 116
.idea/misc.xml Visa fil

@@ -1,43 +1,5 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project version="4">
3
-  <component name="ClientPropertiesManager">
4
-    <properties class="javax.swing.AbstractButton">
5
-      <property name="hideActionText" class="java.lang.Boolean" />
6
-    </properties>
7
-    <properties class="javax.swing.JComponent">
8
-      <property name="html.disable" class="java.lang.Boolean" />
9
-    </properties>
10
-    <properties class="javax.swing.JEditorPane">
11
-      <property name="JEditorPane.w3cLengthUnits" class="java.lang.Boolean" />
12
-      <property name="JEditorPane.honorDisplayProperties" class="java.lang.Boolean" />
13
-      <property name="charset" class="java.lang.String" />
14
-    </properties>
15
-    <properties class="javax.swing.JList">
16
-      <property name="List.isFileList" class="java.lang.Boolean" />
17
-    </properties>
18
-    <properties class="javax.swing.JPasswordField">
19
-      <property name="JPasswordField.cutCopyAllowed" class="java.lang.Boolean" />
20
-    </properties>
21
-    <properties class="javax.swing.JSlider">
22
-      <property name="Slider.paintThumbArrowShape" class="java.lang.Boolean" />
23
-      <property name="JSlider.isFilled" class="java.lang.Boolean" />
24
-    </properties>
25
-    <properties class="javax.swing.JTable">
26
-      <property name="Table.isFileList" class="java.lang.Boolean" />
27
-      <property name="JTable.autoStartsEdit" class="java.lang.Boolean" />
28
-      <property name="terminateEditOnFocusLost" class="java.lang.Boolean" />
29
-    </properties>
30
-    <properties class="javax.swing.JToolBar">
31
-      <property name="JToolBar.isRollover" class="java.lang.Boolean" />
32
-    </properties>
33
-    <properties class="javax.swing.JTree">
34
-      <property name="JTree.lineStyle" class="java.lang.String" />
35
-    </properties>
36
-    <properties class="javax.swing.text.JTextComponent">
37
-      <property name="caretAspectRatio" class="java.lang.Double" />
38
-      <property name="caretWidth" class="java.lang.Integer" />
39
-    </properties>
40
-  </component>
41 3
   <component name="MavenProjectsManager">
42 4
     <option name="originalFiles">
43 5
       <list>
@@ -45,84 +7,7 @@
45 7
       </list>
46 8
     </option>
47 9
   </component>
48
-  <component name="ProjectInspectionProfilesVisibleTreeState">
49
-    <entry key="Project Default">
50
-      <profile-state>
51
-        <expanded-state>
52
-          <State>
53
-            <id />
54
-          </State>
55
-        </expanded-state>
56
-        <selected-state>
57
-          <State>
58
-            <id>Android</id>
59
-          </State>
60
-        </selected-state>
61
-      </profile-state>
62
-    </entry>
63
-  </component>
64 10
   <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
65
-    <output url="file://$PROJECT_DIR$/out" />
66
-  </component>
67
-  <component name="masterDetails">
68
-    <states>
69
-      <state key="GlobalLibrariesConfigurable.UI">
70
-        <settings>
71
-          <splitter-proportions>
72
-            <option name="proportions">
73
-              <list>
74
-                <option value="0.2" />
75
-              </list>
76
-            </option>
77
-          </splitter-proportions>
78
-        </settings>
79
-      </state>
80
-      <state key="JdkListConfigurable.UI">
81
-        <settings>
82
-          <last-edited>1.8</last-edited>
83
-          <splitter-proportions>
84
-            <option name="proportions">
85
-              <list>
86
-                <option value="0.2" />
87
-              </list>
88
-            </option>
89
-          </splitter-proportions>
90
-        </settings>
91
-      </state>
92
-      <state key="ProjectJDKs.UI">
93
-        <settings>
94
-          <last-edited>1.8</last-edited>
95
-          <splitter-proportions>
96
-            <option name="proportions">
97
-              <list>
98
-                <option value="0.2" />
99
-              </list>
100
-            </option>
101
-          </splitter-proportions>
102
-        </settings>
103
-      </state>
104
-      <state key="ProjectLibrariesConfigurable.UI">
105
-        <settings>
106
-          <splitter-proportions>
107
-            <option name="proportions">
108
-              <list>
109
-                <option value="0.2" />
110
-              </list>
111
-            </option>
112
-          </splitter-proportions>
113
-        </settings>
114
-      </state>
115
-      <state key="ScopeChooserConfigurable.UI">
116
-        <settings>
117
-          <splitter-proportions>
118
-            <option name="proportions">
119
-              <list>
120
-                <option value="0.2" />
121
-              </list>
122
-            </option>
123
-          </splitter-proportions>
124
-        </settings>
125
-      </state>
126
-    </states>
11
+    <output url="file://$PROJECT_DIR$/classes" />
127 12
   </component>
128 13
 </project>

+ 124
- 0
.idea/uiDesigner.xml Visa fil

@@ -0,0 +1,124 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="Palette2">
4
+    <group name="Swing">
5
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
6
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
7
+      </item>
8
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
9
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
10
+      </item>
11
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
12
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
13
+      </item>
14
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
15
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
16
+      </item>
17
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
18
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
19
+        <initial-values>
20
+          <property name="text" value="Button" />
21
+        </initial-values>
22
+      </item>
23
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
24
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
25
+        <initial-values>
26
+          <property name="text" value="RadioButton" />
27
+        </initial-values>
28
+      </item>
29
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
30
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
31
+        <initial-values>
32
+          <property name="text" value="CheckBox" />
33
+        </initial-values>
34
+      </item>
35
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
36
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
37
+        <initial-values>
38
+          <property name="text" value="Label" />
39
+        </initial-values>
40
+      </item>
41
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
42
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
43
+          <preferred-size width="150" height="-1" />
44
+        </default-constraints>
45
+      </item>
46
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
47
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
48
+          <preferred-size width="150" height="-1" />
49
+        </default-constraints>
50
+      </item>
51
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
52
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
53
+          <preferred-size width="150" height="-1" />
54
+        </default-constraints>
55
+      </item>
56
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
57
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
58
+          <preferred-size width="150" height="50" />
59
+        </default-constraints>
60
+      </item>
61
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
62
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
63
+          <preferred-size width="150" height="50" />
64
+        </default-constraints>
65
+      </item>
66
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
67
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
68
+          <preferred-size width="150" height="50" />
69
+        </default-constraints>
70
+      </item>
71
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
72
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
73
+      </item>
74
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
75
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
76
+          <preferred-size width="150" height="50" />
77
+        </default-constraints>
78
+      </item>
79
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
80
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
81
+          <preferred-size width="150" height="50" />
82
+        </default-constraints>
83
+      </item>
84
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
85
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
86
+          <preferred-size width="150" height="50" />
87
+        </default-constraints>
88
+      </item>
89
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
90
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
91
+          <preferred-size width="200" height="200" />
92
+        </default-constraints>
93
+      </item>
94
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
95
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
96
+          <preferred-size width="200" height="200" />
97
+        </default-constraints>
98
+      </item>
99
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
100
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
101
+      </item>
102
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
103
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
104
+      </item>
105
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
106
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
107
+      </item>
108
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
109
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
110
+      </item>
111
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
112
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
113
+          <preferred-size width="-1" height="20" />
114
+        </default-constraints>
115
+      </item>
116
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
117
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
118
+      </item>
119
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
120
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
121
+      </item>
122
+    </group>
123
+  </component>
124
+</project>

+ 558
- 396
.idea/workspace.xml
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 8
- 0
pom.xml Visa fil

@@ -7,6 +7,14 @@
7 7
     <groupId>com.zipcodewilmington</groupId>
8 8
     <artifactId>bankaccountlab</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10
+    <dependencies>
11
+        <dependency>
12
+            <groupId>junit</groupId>
13
+            <artifactId>junit</artifactId>
14
+            <version>RELEASE</version>
15
+            <scope>test</scope>
16
+        </dependency>
17
+    </dependencies>
10 18
 
11 19
 
12 20
 </project>

+ 101
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/ATM.java Visa fil

@@ -0,0 +1,101 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import java.util.ArrayList;
4
+import java.util.Scanner;
5
+
6
+public class ATM {
7
+
8
+    private ArrayList<Account> accounts = new ArrayList<Account>();
9
+
10
+    private Account selectedAccount;
11
+
12
+    public void add(Account account) {
13
+        accounts.add(account);
14
+    }
15
+
16
+    public double getTotal() {
17
+        double total = 0.0;
18
+        for (Account account: this.accounts) {
19
+            total += account.getBalance();
20
+        }
21
+        return total;
22
+    }
23
+
24
+    public Account getSelectedAccount() {
25
+        return selectedAccount;
26
+    }
27
+
28
+    public void setSelectedAccount(Account selectedAccount) {
29
+        this.selectedAccount = selectedAccount;
30
+    }
31
+
32
+    public void display(){
33
+        StringBuilder sb = new StringBuilder();
34
+
35
+        int counter = 1;
36
+        for (Account account:this.accounts) {
37
+            sb.append(String.format("%5d. %15s %.2f \n", counter, account.getClass().getSimpleName(), account.getBalance()));
38
+            counter++;
39
+        }
40
+        System.out.println(sb.toString());
41
+    }
42
+
43
+    public void run(){
44
+        this.add(new CheckingAccount(2000));
45
+        this.add(new SavingAccount(1500));
46
+        this.add(new BusinessAccount(3000));
47
+
48
+        String input;
49
+
50
+        while(true){
51
+            if(this.selectedAccount == null){
52
+                this.display();
53
+                input = getInput("Please Select a Account: ");
54
+
55
+                if(input.equalsIgnoreCase("Checkings")){
56
+                    this.selectedAccount = this.accounts.get(0);
57
+                } else if(input.equalsIgnoreCase("Savings")){
58
+                    this.selectedAccount = this.accounts.get(1);
59
+                } else if(input.equalsIgnoreCase("Business")){
60
+                    this.selectedAccount = this.accounts.get(2);
61
+                } if(input.equalsIgnoreCase("Exit")){
62
+                    System.out.println("Thank you for using my ATM");
63
+                    break;
64
+                }
65
+            } else {
66
+                System.out.println("You are selected into your " + this.selectedAccount.getClass().getSimpleName() + "\n");
67
+                System.out.println(this.selectedAccount.getBalance());
68
+                input = getInput("Please Enter Withdraw, Deposit or Check Balance");
69
+
70
+                if(input.equalsIgnoreCase("Withdraw")){
71
+
72
+                    input = getInput("Enter a amount to Withdraw");
73
+                    this.selectedAccount.withdraw(Double.parseDouble(input));
74
+
75
+                } else if(input.equalsIgnoreCase("Deposit")){
76
+
77
+                    input = getInput("Enter a amount to Deposit");
78
+                    this.selectedAccount.deposit(Double.parseDouble(input));
79
+
80
+                } else if(input.equalsIgnoreCase("Check Balance")){
81
+
82
+                    System.out.println(this.selectedAccount.getBalance());
83
+
84
+                } else if(input.equalsIgnoreCase("exit")){
85
+
86
+                    this.selectedAccount = null;
87
+                }
88
+            }
89
+
90
+        }
91
+
92
+    }
93
+
94
+
95
+    public static String getInput(String prompt) {
96
+        System.out.println(prompt);
97
+        Scanner scanner = new Scanner(System.in);
98
+        return scanner.nextLine();
99
+    }
100
+
101
+}

+ 33
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/Account.java Visa fil

@@ -0,0 +1,33 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public abstract class Account {
4
+
5
+
6
+    private double balance;
7
+
8
+
9
+    public Account(double balance){
10
+        this.balance = balance;
11
+    }
12
+
13
+
14
+    public double withdraw(double amount){
15
+
16
+        this.balance = this.balance - amount;
17
+
18
+        return amount;
19
+    }
20
+
21
+
22
+    public double getBalance() {
23
+
24
+        return this.balance;
25
+    }
26
+
27
+    public double deposit(double amount) {
28
+
29
+        balance += amount;
30
+
31
+        return amount;
32
+    }
33
+}

+ 0
- 7
src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java Visa fil

@@ -1,7 +0,0 @@
1
-package com.zipcodewilmington.bankaccountlab;
2
-
3
-/**
4
- * Created by leon on 1/10/18.
5
- */
6
-public class BankAccount {
7
-}

+ 7
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/BusinessAccount.java Visa fil

@@ -0,0 +1,7 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public class BusinessAccount extends Account{
4
+    public BusinessAccount(double balance) {
5
+        super(balance);
6
+    }
7
+}

+ 8
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/CheckingAccount.java Visa fil

@@ -0,0 +1,8 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public class CheckingAccount extends Account {
4
+
5
+    public CheckingAccount(double balance){
6
+        super(balance);
7
+    }
8
+}

+ 7
- 1
src/main/java/com/zipcodewilmington/bankaccountlab/MainApplication.java Visa fil

@@ -4,4 +4,10 @@ package com.zipcodewilmington.bankaccountlab;
4 4
  * Created by leon on 1/10/18.
5 5
  */
6 6
 public class MainApplication {
7
-}
7
+
8
+    public static void main(String[] args) {
9
+        new ATM().run();
10
+
11
+    }
12
+
13
+}

+ 7
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/SavingAccount.java Visa fil

@@ -0,0 +1,7 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public class SavingAccount extends Account {
4
+    public SavingAccount(double balance) {
5
+        super(balance);
6
+    }
7
+}

+ 35
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/ATMTest.java Visa fil

@@ -0,0 +1,35 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
7
+public class ATMTest {
8
+
9
+    ATM atm;
10
+
11
+    @Before
12
+    public void setUp(){
13
+
14
+        atm = new ATM();
15
+        atm.add(new CheckingAccount(3000));
16
+        atm.add(new SavingAccount(4000));
17
+        atm.add(new BusinessAccount(5000));
18
+    }
19
+
20
+
21
+    @Test
22
+    public void getTotal(){
23
+        //expected
24
+        double expected = 12000;
25
+
26
+        //actual
27
+        double actual = atm.getTotal();
28
+
29
+        Assert.assertEquals(expected,actual,0);
30
+    }
31
+
32
+
33
+
34
+
35
+}

+ 0
- 7
src/test/java/com/zipcodewilmington/bankaccountlab/BankAccountTest.java Visa fil

@@ -1,7 +0,0 @@
1
-package com.zipcodewilmington.bankaccountlab;
2
-
3
-/**
4
- * Created by leon on 1/10/18.
5
- */
6
-public class BankAccountTest {
7
-}

+ 72
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/BusinessAccountTest.java Visa fil

@@ -0,0 +1,72 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
7
+public class BusinessAccountTest {
8
+
9
+    BusinessAccount ba;
10
+
11
+
12
+    @Before
13
+    public void setUp(){
14
+
15
+        ba = new BusinessAccount(5000);
16
+
17
+    }
18
+
19
+    @Test
20
+    public void withdrawTest(){
21
+        //when
22
+        ba.withdraw(4999);
23
+
24
+        //expected
25
+        double expected = 1;
26
+
27
+        //actual
28
+        double actual = ba.getBalance();
29
+
30
+        Assert.assertEquals(expected,actual,0);
31
+
32
+    }
33
+
34
+
35
+
36
+    @Test
37
+    public void deposit(){
38
+        //when
39
+        ba.deposit(1000);
40
+
41
+        //expected
42
+        double expected = 6000;
43
+
44
+        //actual
45
+        double actual = ba.getBalance();
46
+
47
+        Assert.assertEquals(expected,actual,0);
48
+    }
49
+
50
+
51
+    @Test
52
+    public void getBalance(){
53
+        //expected
54
+        double expected = 5000;
55
+
56
+        //actual
57
+        double actual = ba.getBalance();
58
+
59
+        Assert.assertEquals(expected,actual,0);
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+    }
68
+
69
+
70
+
71
+
72
+}

+ 65
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/CheckingAccountTest.java Visa fil

@@ -0,0 +1,65 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
7
+public class CheckingAccountTest {
8
+
9
+
10
+    //CheckingAccount ca = new CheckingAccount(5000);
11
+
12
+
13
+    CheckingAccount ca;
14
+
15
+    @Before
16
+    public void setUp(){
17
+        ca = new CheckingAccount(5000);
18
+    }
19
+
20
+
21
+    @Test
22
+    public void withdrawTest(){
23
+        //when
24
+        ca.withdraw(500);
25
+
26
+        //expected
27
+        double expecetd = 4500;
28
+
29
+        //actual
30
+        double actual = ca.getBalance();
31
+
32
+        Assert.assertEquals(expecetd,actual,0);
33
+    }
34
+
35
+
36
+    @Test
37
+    public void deposit(){
38
+        //when
39
+        ca.deposit(500);
40
+
41
+        //expected
42
+        double expected = 5500;
43
+
44
+        //actual
45
+        double actual = ca.getBalance();
46
+
47
+        Assert.assertEquals(expected,actual,0);
48
+    }
49
+
50
+
51
+    @Test
52
+    public void getBalance(){
53
+        //expected
54
+        double expected = 5000;
55
+
56
+        //actual
57
+        double actual = ca.getBalance();
58
+
59
+        Assert.assertEquals(expected,actual,0);
60
+    }
61
+
62
+
63
+
64
+
65
+}

+ 62
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/SavingsAccountTest.java Visa fil

@@ -0,0 +1,62 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
7
+public class SavingsAccountTest {
8
+
9
+    SavingAccount sa;
10
+
11
+
12
+    @Before
13
+    public void setUp(){
14
+        sa = new SavingAccount(5000);
15
+    }
16
+
17
+
18
+    @Test
19
+    public void withdraw(){
20
+        //when
21
+        sa.withdraw(1000);
22
+
23
+        //expected
24
+        double expected = 4000;
25
+
26
+        //actual
27
+        double actual = sa.getBalance();
28
+
29
+        Assert.assertEquals(expected,actual,0);
30
+    }
31
+
32
+
33
+
34
+    @Test
35
+    public void deposit(){
36
+        //when
37
+        sa.deposit(1000);
38
+
39
+        //expected
40
+        double expected = 6000;
41
+
42
+        //actual
43
+        double actual = sa.getBalance();
44
+
45
+        Assert.assertEquals(expected,actual,0);
46
+    }
47
+
48
+
49
+    @Test
50
+    public void getBalance(){
51
+        //expected
52
+        double expected = 5000;
53
+
54
+        //actual
55
+        double actual = sa.getBalance();
56
+
57
+        Assert.assertEquals(expected,actual,0);
58
+    }
59
+
60
+
61
+
62
+}