#16 Tommy's Abstract Bank Account

Open
TSRogers28 wants to merge 1 commits from TSRogers28/ZCW-Inheritance-AbstractBankAccount:master into master

+ 13
- 0
.idea/libraries/Maven__junit_junit_4_12.xml View File

@@ -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 View File

@@ -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>

+ 124
- 0
.idea/uiDesigner.xml View File

@@ -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>

+ 775
- 340
.idea/workspace.xml
File diff suppressed because it is too large
View File


+ 14
- 0
pom.xml View File

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

+ 42
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/ATM.java View File

@@ -0,0 +1,42 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+/**
4
+ * Created by leon on 1/10/18.
5
+ */
6
+public class ATM {
7
+
8
+    BankAccount bankAccount;
9
+
10
+    public ATM(){
11
+        bankAccount = new BankAccount();
12
+    }
13
+
14
+    public BankAccount getBankAccount() {
15
+        return bankAccount;
16
+    }
17
+
18
+    public int getSavings(){
19
+    return bankAccount.getSavingsAccount().getBalance();
20
+    }
21
+
22
+    public void setSavings(int amountWithdrawn){
23
+        bankAccount.getSavingsAccount().setBalance(getSavings()-amountWithdrawn);
24
+    }
25
+
26
+    public int getBusiness(){
27
+        return bankAccount.getBusinessAccount().getBalance();
28
+    }
29
+
30
+    public void setBusiness(int amountWithdrawn){
31
+        bankAccount.getBusinessAccount().setBalance(getBusiness()-amountWithdrawn);
32
+    }
33
+
34
+    public int getChecking(){
35
+        return bankAccount.getCheckingAccount().getBalance();
36
+    }
37
+
38
+    public void setChecking(int amountWithdrawn){
39
+        bankAccount.getCheckingAccount().setBalance(getChecking()-amountWithdrawn);
40
+    }
41
+
42
+}

+ 23
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/Account.java View File

@@ -0,0 +1,23 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public abstract class Account {
4
+
5
+    int balance;
6
+
7
+    public Account(){
8
+
9
+    }
10
+
11
+    public Account(int balance) {
12
+        this.balance = balance;
13
+    }
14
+
15
+    public int getBalance() {
16
+        return balance;
17
+    }
18
+
19
+    public void setBalance(int balance) {
20
+        this.balance = balance;
21
+    }
22
+
23
+}

+ 31
- 1
src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java View File

@@ -3,5 +3,35 @@ package com.zipcodewilmington.bankaccountlab;
3 3
 /**
4 4
  * Created by leon on 1/10/18.
5 5
  */
6
-public class BankAccount {
6
+public class BankAccount extends Account{
7
+    Account businessAccount;
8
+    Account savingsAccount;
9
+    Account checkingAccount;
10
+    Account [] accounts;
11
+
12
+    public BankAccount(){
13
+        businessAccount = new BusinessAccount(100000);
14
+        savingsAccount = new SavingsAccount(80000);
15
+        checkingAccount = new CheckingAccount(10000);
16
+        accounts = new Account[]{businessAccount, savingsAccount, checkingAccount};
17
+    }
18
+
19
+    public BankAccount(int balance) {
20
+        super(balance);
21
+    }
22
+
23
+    public Account getBusinessAccount() {
24
+        return accounts[0];
25
+    }
26
+
27
+
28
+
29
+    public Account getSavingsAccount() {
30
+        return accounts[1];
31
+    }
32
+
33
+
34
+    public Account getCheckingAccount() {
35
+        return accounts[2];
36
+    }
7 37
 }

+ 13
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/BusinessAccount.java View File

@@ -0,0 +1,13 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public class BusinessAccount extends BankAccount {
4
+
5
+
6
+
7
+
8
+    public BusinessAccount(int balance) {
9
+        super(balance);
10
+    }
11
+
12
+
13
+}

+ 8
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/CheckingAccount.java View File

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

+ 0
- 7
src/main/java/com/zipcodewilmington/bankaccountlab/MainApplication.java View File

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

+ 9
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/SavingsAccount.java View File

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

+ 76
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/ATMTest.java View File

@@ -0,0 +1,76 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import junit.extensions.TestSetup;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
7
+import static org.junit.Assert.*;
8
+
9
+public class ATMTest {
10
+
11
+    ATM atm;
12
+    @Before
13
+    public void setup(){
14
+        atm = new ATM();
15
+    }
16
+
17
+
18
+    @Test
19
+    public void getSavings() {
20
+        int expected = 80000;
21
+
22
+        int actual = atm.getSavings();
23
+
24
+        assertEquals(expected, actual);
25
+    }
26
+
27
+    @Test
28
+    public void setSavings() {
29
+        atm.setSavings(10000);
30
+
31
+        int expected = 70000;
32
+        int actual = atm.getSavings();
33
+
34
+        assertEquals(expected, actual);
35
+    }
36
+
37
+    @Test
38
+    public void getBusiness() {
39
+        int expected = 100000;
40
+
41
+        int actual = atm.getBusiness();
42
+
43
+        assertEquals(expected, actual);
44
+    }
45
+
46
+    @Test
47
+    public void setBusiness() {
48
+        atm.setBusiness(30000);
49
+
50
+        int expected = 70000;
51
+
52
+        int actual = atm.getBusiness();
53
+
54
+        assertEquals(expected, actual);
55
+    }
56
+
57
+    @Test
58
+    public void getChecking() {
59
+        int expected = 10000;
60
+
61
+        int actual = atm.getChecking();
62
+
63
+        assertEquals(expected, actual);
64
+    }
65
+
66
+    @Test
67
+    public void setChecking() {
68
+        atm.setChecking(2000);
69
+
70
+        int expected = 8000;
71
+
72
+        int actual = atm.getChecking();
73
+
74
+        assertEquals(expected, actual);
75
+    }
76
+}