Aleena Rose-Mathew hace 8 años
padre
commit
7037ee2dd6

+ 13
- 0
.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml Ver fichero

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

+ 13
- 0
.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_2_0.xml Ver fichero

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

+ 13
- 0
.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_2_0.xml Ver fichero

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

+ 13
- 0
.idea/libraries/Maven__org_opentest4j_opentest4j_1_1_0.xml Ver fichero

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

+ 1
- 62
.idea/misc.xml Ver fichero

@@ -61,68 +61,7 @@
61 61
       </profile-state>
62 62
     </entry>
63 63
   </component>
64
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
64
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8 (1)" project-jdk-type="JavaSDK">
65 65
     <output url="file://$PROJECT_DIR$/out" />
66 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>
127
-  </component>
128 67
 </project>

+ 715
- 352
.idea/workspace.xml
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 1
- 1
README.md Ver fichero

@@ -1,6 +1,6 @@
1 1
 # Abstract Class
2 2
 
3
-## Bank Account Manager
3
+ ## Bank Account Manager
4 4
 
5 5
 ## Objectives
6 6
 

+ 8
- 1
pom.xml Ver fichero

@@ -8,5 +8,12 @@
8 8
     <artifactId>bankaccountlab</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10 10
 
11
-
11
+    <dependencies>
12
+        <dependency>
13
+            <groupId>org.junit.jupiter</groupId>
14
+            <artifactId>junit-jupiter-api</artifactId>
15
+            <version>RELEASE</version>
16
+            <scope>test</scope>
17
+        </dependency>
18
+    </dependencies>
12 19
 </project>

+ 82
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/ATM.java Ver fichero

@@ -0,0 +1,82 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+import java.util.*;
3
+public class ATM {
4
+    Scanner input = new Scanner(System.in);
5
+    BusinessAccount businessAccount;
6
+    SavingAccount savingAccount;
7
+    CheckingAccount checkingAccount;
8
+
9
+    Boolean repeat=true;
10
+    BankAccount[] personalAccounts;
11
+    public ATM() {
12
+
13
+         businessAccount = new BusinessAccount(7000);
14
+         savingAccount = new SavingAccount(6000);
15
+         checkingAccount = new CheckingAccount(500);
16
+         personalAccounts = new BankAccount[]{businessAccount,savingAccount, checkingAccount};
17
+         accountChoice();
18
+    }
19
+
20
+    public void accountChoice()
21
+    {
22
+        while(repeat) {
23
+            System.out.println("\nWhich Account you want to operate\n1.Business Account\n2.Saving Account\n3.Checking Account\n4.Exit");
24
+            int accountChoice = input.nextInt();
25
+            if (accountChoice == 1) {
26
+                BankAccount userSelection=personalAccounts[0];
27
+                System.out.printf("Your Current Business Account balance is %d", businessAccount.getBalance());
28
+                accountChoice(userSelection);
29
+            }
30
+            if (accountChoice == 2) {
31
+                BankAccount userSelection=personalAccounts[1];
32
+                System.out.printf("Your Current Saving Account balance is %d", savingAccount.getBalance());
33
+                accountChoice(userSelection);
34
+
35
+            }
36
+            if (accountChoice == 3) {
37
+                BankAccount userSelection=personalAccounts[2];
38
+                System.out.printf("Your Current Checking Account balance is %d", checkingAccount.getBalance());
39
+                accountChoice(userSelection);
40
+            }
41
+            if(accountChoice==4)
42
+            {
43
+                System.exit(0);
44
+            }
45
+        }
46
+    }
47
+    public void accountChoice(BankAccount userSelection)
48
+    {
49
+
50
+        System.out.println("\nWhat u wanna do\n1.Credit\n2.Debit\n3.Go back to menu");
51
+        int choice=input.nextInt();
52
+
53
+
54
+        if (choice == 1)//Credit
55
+        {
56
+            System.out.println("Enter the amount ?");
57
+            int amount=input.nextInt();
58
+            userSelection.credit(amount);
59
+
60
+        }
61
+        else if (choice == 2)//Debit
62
+        {
63
+            System.out.println("Enter the amount ?");
64
+            int amount=input.nextInt();
65
+            userSelection.debit(amount);
66
+
67
+        }
68
+        else if (choice == 3)//Go back to menu
69
+        {
70
+            accountChoice();
71
+        }
72
+        display(userSelection);
73
+    }
74
+    public void display(BankAccount userSelection)
75
+    {
76
+        System.out.println("Your current balance is "+userSelection.getBalance());
77
+    }
78
+
79
+
80
+}
81
+
82
+

+ 7
- 1
src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java Ver fichero

@@ -3,5 +3,11 @@ package com.zipcodewilmington.bankaccountlab;
3 3
 /**
4 4
  * Created by leon on 1/10/18.
5 5
  */
6
-public class BankAccount {
6
+public abstract class BankAccount {
7
+
8
+    private int balance;
9
+    public abstract void setBalance(int balance);
10
+    public abstract int getBalance();
11
+    public abstract void credit(int balance);
12
+    public abstract void debit(int amount);
7 13
 }

+ 27
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/BusinessAccount.java Ver fichero

@@ -0,0 +1,27 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public class BusinessAccount extends BankAccount {
4
+    //implement the abstract class functions
5
+    private int balance;
6
+    public BusinessAccount(int balance)
7
+    {
8
+        super();
9
+        this.balance=balance;
10
+    }
11
+    public void setBalance(int balance)
12
+    {
13
+        this.balance=balance;
14
+    }
15
+    public int getBalance()
16
+    {
17
+        return this.balance;
18
+    }
19
+    public void credit(int amount)
20
+    {
21
+        this.setBalance(this.getBalance()+amount);
22
+    }
23
+    public void debit(int amount)
24
+    {
25
+        this.setBalance(this.getBalance()-amount);
26
+    }
27
+}

+ 26
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/CheckingAccount.java Ver fichero

@@ -0,0 +1,26 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public class CheckingAccount extends BankAccount {
4
+    private int balance;
5
+    public CheckingAccount(int balance)
6
+    {
7
+        super();
8
+        this.balance=balance;
9
+    }
10
+    public void setBalance(int balance)
11
+    {
12
+        this.balance=balance;
13
+    }
14
+    public int getBalance()
15
+    {
16
+        return this.balance;
17
+    }
18
+    public void credit(int amount)
19
+    {
20
+        setBalance(this.getBalance()+amount);
21
+    }
22
+    public void debit(int amount)
23
+    {
24
+        setBalance(this.getBalance()-amount);
25
+    }
26
+}

+ 5
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/MainApplication.java Ver fichero

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

+ 26
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/SavingAccount.java Ver fichero

@@ -0,0 +1,26 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public class SavingAccount extends BankAccount  {
4
+    private int balance;
5
+    public SavingAccount(int balance)
6
+    {
7
+        super();
8
+        this.balance=balance;
9
+    }
10
+    public void setBalance(int balance)
11
+    {
12
+        this.balance=balance;
13
+    }
14
+    public int getBalance()
15
+    {
16
+        return this.balance;
17
+    }
18
+    public void credit(int amount)
19
+    {
20
+        setBalance(this.getBalance()+amount);
21
+    }
22
+    public void debit(int amount)
23
+    {
24
+        setBalance(this.getBalance()-amount);
25
+    }
26
+}

+ 1
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/BankAccountTest.java Ver fichero

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

+ 27
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/BuisnessAccountTest.java Ver fichero

@@ -0,0 +1,27 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import org.junit.jupiter.api.Test;
4
+
5
+public class BuisnessAccountTest {
6
+
7
+    @Test
8
+    public void testCredit()
9
+    {
10
+        BusinessAccount sa=new BusinessAccount(2000);
11
+        int expected=2500;
12
+        sa.credit(500);
13
+        int actual=sa.getBalance();
14
+        Assert.assertEquals(expected, actual);
15
+
16
+    }
17
+    @Test
18
+    public void testDebit()
19
+    {
20
+        BusinessAccount sa=new BusinessAccount(2000);
21
+        int expected=1500;
22
+        sa.credit(500);
23
+        int actual=sa.getBalance();
24
+        Assert.assertEquals(expected, actual);
25
+
26
+    }
27
+}

+ 26
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/CheckingAccountTest.java Ver fichero

@@ -0,0 +1,26 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import org.junit.jupiter.api.Test;
4
+
5
+public class CheckingAccountTest {
6
+    SavingAccount sa=new SavingAccount(2000);
7
+    @Test
8
+    public void testCredit()
9
+    {
10
+        int expected=2500;
11
+        sa.credit(500);
12
+        int actual=sa.getBalance();
13
+        Assert.assertEquals(expected, actual);
14
+
15
+    }
16
+    @Test
17
+    public void testDebit()
18
+    {
19
+        int expected=1500;
20
+        sa.credit(500);
21
+        int actual=sa.getBalance();
22
+        Assert.assertEquals(expected, actual);
23
+
24
+    }
25
+
26
+}

+ 26
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/SavingsAccountTest.java Ver fichero

@@ -0,0 +1,26 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import org.junit.jupiter.api.BeforeAll;
4
+import org.junit.jupiter.api.Test;
5
+
6
+public class SavingsAccountTest {
7
+    SavingAccount sa=new SavingAccount(2000);
8
+    @Test
9
+    public void testCredit()
10
+    {
11
+        int expected=2500;
12
+        sa.credit(500);
13
+        int actual=sa.getBalance();
14
+        Assert.assertEquals(expected, actual);
15
+
16
+    }
17
+    @Test
18
+    public void testDebit()
19
+    {
20
+        int expected=1500;
21
+        sa.credit(500);
22
+        int actual=sa.getBalance();
23
+        Assert.assertEquals(expected, actual);
24
+
25
+    }
26
+}