Vincent Sima 8 년 전
부모
커밋
716b635241

+ 13
- 0
.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml 파일 보기

@@ -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_0_3.xml 파일 보기

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

+ 13
- 0
.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_0_3.xml 파일 보기

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

+ 13
- 0
.idea/libraries/Maven__org_opentest4j_opentest4j_1_0_0.xml 파일 보기

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

+ 491
- 370
.idea/workspace.xml
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 8
- 0
pom.xml 파일 보기

@@ -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>org.junit.jupiter</groupId>
13
+            <artifactId>junit-jupiter-api</artifactId>
14
+            <version>5.0.3</version>
15
+            <scope>test</scope>
16
+        </dependency>
17
+    </dependencies>
10 18
 
11 19
 
12 20
 </project>

+ 27
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/Account.java 파일 보기

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

+ 83
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/Atm.java 파일 보기

@@ -0,0 +1,83 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import java.util.Scanner;
4
+
5
+public class Atm {
6
+    SavingsAccount sa = new SavingsAccount(100000);
7
+    CheckingAccount ca = new CheckingAccount(4000);
8
+    BusinessAccount ba = new BusinessAccount(500000);
9
+    boolean running = false;
10
+
11
+
12
+    public void start() {
13
+        running = true;
14
+        while (running == true) {
15
+
16
+            System.out.println("Welcome to the Banky Wank!");
17
+            System.out.println("Which account would you like to access?\n\n1. Checking\n2. Savings\n3. Business\n\n4. Exit");
18
+            System.out.println("Please select 1, 2, 3, or 4");
19
+            int accountChoice = intScanner();
20
+            if (accountChoice == 1) {
21
+                System.out.println("Balance: $" + ca.getBalance());
22
+                actions(ca);
23
+            } else if (accountChoice == 2) {
24
+                System.out.println("Balance: $" + sa.getBalance());
25
+                actions(sa);
26
+            } else if (accountChoice == 3) {
27
+                System.out.println("Balance: $" + ba.getBalance());
28
+                actions(ba);
29
+            } else if (accountChoice == 4) {
30
+                running = false;
31
+            } else {
32
+                System.out.println("Please try again");
33
+            }
34
+
35
+        }
36
+    }
37
+
38
+
39
+    public void actions(Account p) {
40
+        System.out.println("Would action would you like to take?\n1. Withdraw\n2. Deposit\n");
41
+        System.out.println("Please select 1 or 2");
42
+        int actionChoice = intScanner();
43
+        if (actionChoice == 1) {
44
+            selectWithdrawalAmount(p);
45
+        } else if (actionChoice == 2) {
46
+            selectDepositAmount(p);
47
+        } else {
48
+            System.out.println("Please try again");
49
+        }
50
+
51
+    }
52
+
53
+    public void selectDepositAmount(Account p) {
54
+        System.out.println("How much would you like to deposit?");
55
+        int dp = intScanner();
56
+        p.deposit(dp);
57
+        System.out.println(dp + " deposited, your new balance is: " + p.getBalance());
58
+    }
59
+
60
+    public void selectWithdrawalAmount(Account p) {
61
+        System.out.println("How much would you like to withdraw?");
62
+        int wd = intScanner();
63
+        if (wd < p.getBalance()) {
64
+            p.withdrawal(wd);
65
+            System.out.println(wd + " withdrawn, your new balance is: " + p.getBalance());
66
+        } else {
67
+            System.out.println("You don't have enough in your account, sorry!");
68
+        }
69
+    }
70
+
71
+    public int intScanner() {
72
+        Scanner sc = new Scanner(System.in);
73
+        int input = 0;
74
+        if (sc.hasNextInt()) {
75
+            input = sc.nextInt();
76
+
77
+        } else {
78
+            System.out.println("Invalid input! Try Again!");
79
+        }
80
+        return input;
81
+    }
82
+
83
+}

+ 0
- 7
src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java 파일 보기

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

+ 8
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/BusinessAccount.java 파일 보기

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

+ 9
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/CheckingAccount.java 파일 보기

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

+ 5
- 3
src/main/java/com/zipcodewilmington/bankaccountlab/MainApplication.java 파일 보기

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

+ 9
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/SavingsAccount.java 파일 보기

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

+ 27
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/AccountTest.java 파일 보기

@@ -0,0 +1,27 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import org.junit.jupiter.api.Test;
4
+
5
+import static org.junit.jupiter.api.Assertions.*;
6
+
7
+class AccountTest {
8
+
9
+    @Test
10
+    void withdrawal() {
11
+        CheckingAccount ca = new CheckingAccount(10000);
12
+        ca.withdrawal(500);
13
+        double actual = ca.getBalance();
14
+        double expected = 9500;
15
+        assertEquals(expected, actual);
16
+
17
+    }
18
+
19
+    @Test
20
+    void deposit() {
21
+        CheckingAccount ca = new CheckingAccount(100000);
22
+        ca.deposit(500);
23
+        double actual = ca.getBalance();
24
+        double expected = 100500;
25
+        assertEquals(expected, actual);
26
+    }
27
+}

+ 0
- 7
src/test/java/com/zipcodewilmington/bankaccountlab/BankAccountTest.java 파일 보기

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

+ 19
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/BusinessAccountTest.java 파일 보기

@@ -0,0 +1,19 @@
1
+//package com.zipcodewilmington.bankaccountlab;
2
+//
3
+//import org.junit.jupiter.api.Test;
4
+//
5
+//import static org.junit.jupiter.api.Assertions.*;
6
+//
7
+//class BusinessAccountTest {
8
+//
9
+//    @Test
10
+//    void setCredits() {
11
+//        {
12
+//            BusinessAccount ba = new BusinessAccount();
13
+//            ba.setCredits(1000);
14
+//            int actual = ba.getCredits();
15
+//            int expected = 1000;
16
+//            assertEquals(actual, expected);
17
+//        }
18
+//    }
19
+//}

+ 17
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/CheckingAccountTest.java 파일 보기

@@ -0,0 +1,17 @@
1
+//package com.zipcodewilmington.bankaccountlab;
2
+//
3
+//import org.junit.jupiter.api.Test;
4
+//
5
+//import static org.junit.jupiter.api.Assertions.*;
6
+//
7
+//class CheckingAccountTest {
8
+//
9
+//    @Test
10
+//    void settersAndGetters() {
11
+//        CheckingAccount ca = new CheckingAccount();
12
+//        ca.setCredits(1000);
13
+//        int actual = ca.getCredits();
14
+//        int expected = 1000;
15
+//        assertEquals(actual, expected);
16
+//    }
17
+//}

+ 10
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/SavingsAccountTest.java 파일 보기

@@ -0,0 +1,10 @@
1
+//package com.zipcodewilmington.bankaccountlab;
2
+//
3
+//import org.junit.jupiter.api.Test;
4
+//
5
+//import static org.junit.jupiter.api.Assertions.*;
6
+//
7
+//class SavingsAccountTest {
8
+//
9
+//
10
+//}