Arin Turpin 8 yıl önce
ebeveyn
işleme
aecc2ae4ef

+ 13
- 0
.idea/libraries/Maven__junit_junit_4_12.xml Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

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

+ 546
- 366
.idea/workspace.xml
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 8
- 0
pom.xml Dosyayı Görüntüle

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

+ 67
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/Account.java Dosyayı Görüntüle

@@ -0,0 +1,67 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public abstract class Account {
4
+
5
+    private String name;
6
+    private String address;
7
+    private String email;
8
+    public int pin;
9
+    public double balance;
10
+
11
+
12
+    public Account(){
13
+        this.balance = 3333.33;
14
+    }
15
+
16
+
17
+
18
+    public void setName(String name){
19
+        this.name = name;
20
+    }
21
+
22
+    public String getName(){
23
+        System.out.println(name);
24
+        return name;
25
+    }
26
+
27
+
28
+
29
+    public void setAddress(String address){
30
+        this.address = address;
31
+    }
32
+
33
+    public String getAddress(){
34
+        System.out.println(address);
35
+        return address;
36
+    }
37
+
38
+
39
+
40
+
41
+    public void setEmail(String email){
42
+        this.email = email;
43
+    }
44
+
45
+    public String getEmail(){
46
+        System.out.println(email);
47
+        return email;
48
+    }
49
+
50
+
51
+
52
+    public void setPin(int pin){
53
+        this.pin = pin;
54
+    }
55
+
56
+    public int getPin(){
57
+        System.out.println(pin);
58
+        return pin;
59
+    }
60
+
61
+
62
+
63
+    public double getBalance(){
64
+        System.out.println(balance);
65
+        return balance;
66
+    }
67
+}

+ 38
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/Atm.java Dosyayı Görüntüle

@@ -0,0 +1,38 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public class Atm {
4
+
5
+
6
+    private double balance;
7
+    private int pin;
8
+
9
+    public double getBalance(Account account){
10
+        System.out.println(account.getBalance());
11
+        return account.getBalance();
12
+    }
13
+
14
+    public double depositMoney(Account account, double depositing){
15
+        account.balance = account.balance + depositing;
16
+        return this.balance;
17
+    }
18
+
19
+    public double withdrawMoney(Account account, double withdrawing){
20
+        account.balance = account.balance - withdrawing;
21
+        return this.balance;
22
+    }
23
+
24
+    public void changePin(Account account, int newPin){
25
+        account.pin = pin;
26
+    }
27
+
28
+
29
+    /*
30
+    Maybe for later
31
+    public void transferMoney(Account accountToTransferFrom, Account accountToTransferTo, int amountToTransfer){
32
+        accountToTransferFrom.withdraw
33
+    }
34
+
35
+     */
36
+
37
+
38
+}

+ 0
- 7
src/main/java/com/zipcodewilmington/bankaccountlab/BankAccount.java Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

@@ -0,0 +1,7 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public class BusinessAccount extends Account{
4
+
5
+    public BusinessAccount(String name, String email, String address, int pin, long accountNumber, double balance) {
6
+    }
7
+}

+ 21
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/CheckingAccount.java Dosyayı Görüntüle

@@ -0,0 +1,21 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public class CheckingAccount extends Account {
4
+
5
+   // CheckingAccount checkingAccount = new CheckingAccount();
6
+
7
+    public CheckingAccount(){
8
+
9
+    }
10
+
11
+    public CheckingAccount(String name, String email, String address, int pin, long accountNumber, double balance) {
12
+
13
+    }
14
+
15
+    public CheckingAccount(double balance){
16
+        this.balance = balance;
17
+    }
18
+
19
+    public void pay(double amountToPay){
20
+    }
21
+}

+ 135
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/MainApplication.java Dosyayı Görüntüle

@@ -1,7 +1,142 @@
1 1
 package com.zipcodewilmington.bankaccountlab;
2 2
 
3
+import com.sun.tools.javac.comp.Check;
4
+import sun.applet.Main;
5
+
6
+import java.util.Scanner;
7
+
3 8
 /**
4 9
  * Created by leon on 1/10/18.
5 10
  */
11
+
6 12
 public class MainApplication {
13
+
14
+    private String name;
15
+    private String email;
16
+    private String address;
17
+    private int pin;
18
+    private boolean runCommandCenter;
19
+    private CheckingAccount checkingAccount;
20
+    private BusinessAccount businessAccount;
21
+    private SavingsAccount savingsAccount;
22
+
23
+
24
+
25
+
26
+    Atm atm = new Atm();
27
+
28
+    public void main(String[] vv) {
29
+
30
+        while(runCommandCenter){
31
+            commandCenter();
32
+        }
33
+
34
+        System.out.println("Baller ATM only...");
35
+        MainApplication mainApplication = new MainApplication(name, email, address, pin);
36
+
37
+    }
38
+
39
+
40
+    public MainApplication(String name, String email, String address, int pin) {
41
+
42
+        long accountNumber = Math.round(Math.random() * 999999999);
43
+        double balance = 00000.00;
44
+
45
+        createBusinessAccount(name, email, address, pin, accountNumber, balance);
46
+        createSavingsAccount(name, email, address, pin, accountNumber, balance);
47
+        createCheckingAccount(name, email, address, pin, accountNumber, balance);
48
+
49
+
50
+    }
51
+
52
+    public void commandCenter(){
53
+
54
+        Scanner scanner = new Scanner(System.in);
55
+
56
+        System.out.println("Choose a command");
57
+        System.out.println("'1' - Get the balance of your Checking Account \n'2' - Get the balance of your Savings Account \n'3' - Get balance of your Business Account\n'4' - Deposit money to your Checking Account\n'5' - Deposit money to your Savings Account\n'6' - Deposit money to your Business Account\n'7' - Withdraw money from your Checking Account\n'8' - Withdraw money from your Savings Account\n'9' - Withdraw money from your Business Account\n'10' - Change the pin of your accounts\n'11' - Transfer funds between accounts");
58
+        int userInput = scanner.nextInt();
59
+
60
+        switch(userInput){
61
+            case 1:
62
+                System.out.println("Your Checking Account balance is: " + checkingAccount.getBalance());
63
+                break;
64
+
65
+            case 2:
66
+                System.out.println("Your Savings Account balance is: " + savingsAccount.getBalance());
67
+                break;
68
+
69
+            case 3:
70
+                System.out.println("Your Business Account balance is: " + businessAccount.getBalance());
71
+                break;
72
+
73
+            case 4:
74
+                System.out.println("How much money would you like to deposit into your Checking Account?");
75
+                atm.depositMoney(checkingAccount, scanner.nextDouble());
76
+                System.out.println("Money deposited.");
77
+                break;
78
+
79
+            case 5:
80
+                System.out.println("How much money would you like to deposit into your Savings Account?");
81
+                atm.depositMoney(savingsAccount, scanner.nextDouble());
82
+                System.out.println("Money deposited.");
83
+                break;
84
+
85
+            case 6:
86
+                System.out.println("How much money would you like to deposit into your Business Account?");
87
+                atm.depositMoney(businessAccount, scanner.nextDouble());
88
+                System.out.println("Money deposited.");
89
+                break;
90
+
91
+            case 7:
92
+                System.out.println("How much money would you like to withdraw from your Checking Account?");
93
+                atm.withdrawMoney(checkingAccount, scanner.nextDouble());
94
+                System.out.println("Money withdrawn.");
95
+                break;
96
+
97
+            case 8:
98
+                System.out.println("How much money would you like to withdraw from your Savings Account?");
99
+                atm.withdrawMoney(savingsAccount, scanner.nextDouble());
100
+                System.out.println("Money withdrawn.");
101
+                break;
102
+
103
+            case 9:
104
+                System.out.println("How much money would you like to withdraw from your Business Account?");
105
+                atm.withdrawMoney(businessAccount, scanner.nextDouble());
106
+                System.out.println("Money withdrawn");
107
+                break;
108
+
109
+            case 10:
110
+                System.out.println("Enter a new pin number.");
111
+                atm.changePin(businessAccount, scanner.nextInt());
112
+                //might have to change all of the pin number individually...
113
+
114
+        }
115
+
116
+    }
117
+
118
+
119
+
120
+
121
+
122
+    public CheckingAccount createCheckingAccount(String name, String email, String address, int pin, long accountNumber, double balance){
123
+        CheckingAccount checkingAccount = new CheckingAccount(name, email, address, pin, accountNumber, balance);
124
+        this.checkingAccount = checkingAccount;
125
+        return this.checkingAccount;
126
+
127
+    }
128
+
129
+    public BusinessAccount createBusinessAccount(String name, String email, String address, int pin, long accountNumber, double balance){
130
+        BusinessAccount businessAccount = new BusinessAccount(name, email, address, pin, accountNumber, balance);
131
+        this.businessAccount = businessAccount;
132
+        return this.businessAccount;
133
+
134
+    }
135
+
136
+    public SavingsAccount createSavingsAccount(String name, String email, String address, int pin, long accountNumber, double balance){
137
+        SavingsAccount savingsAccount = new SavingsAccount(name, email, address, pin, accountNumber, balance);
138
+        this.savingsAccount = savingsAccount;
139
+        return this.savingsAccount;
140
+
141
+    }
7 142
 }

+ 7
- 0
src/main/java/com/zipcodewilmington/bankaccountlab/SavingsAccount.java Dosyayı Görüntüle

@@ -0,0 +1,7 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+public class SavingsAccount extends Account {
4
+
5
+    public SavingsAccount(String name, String email, String address, int pin, long accountNumber, double balance) {
6
+    }
7
+}

+ 0
- 7
src/test/java/com/zipcodewilmington/bankaccountlab/BankAccountTest.java Dosyayı Görüntüle

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

+ 70
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/CheckingAccountTest.java Dosyayı Görüntüle

@@ -0,0 +1,70 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import com.sun.tools.javac.comp.Check;
4
+import org.junit.Assert;
5
+import org.junit.Test;
6
+
7
+public class CheckingAccountTest {
8
+
9
+
10
+    @Test
11
+    public void test_Get_Set_Name() {
12
+        CheckingAccount checkingAccount = new CheckingAccount();
13
+
14
+        checkingAccount.setName("Kenneth");
15
+        String expected = "Kenneth";
16
+        String actual = checkingAccount.getName();
17
+        Assert.assertEquals(expected, actual);
18
+    }
19
+
20
+    @Test
21
+    public void test_Get_Set_Address() {
22
+        CheckingAccount checkingAccount = new CheckingAccount();
23
+
24
+        checkingAccount.setAddress("867 Anton Lane");
25
+        String expected = "867 Anton Lane";
26
+        String actual = checkingAccount.getAddress();
27
+        Assert.assertEquals(expected, actual);
28
+    }
29
+
30
+    @Test
31
+    public void test_Get_Set_Email() {
32
+        CheckingAccount checkingAccount = new CheckingAccount();
33
+
34
+        checkingAccount.setEmail("peace_459@live.com");
35
+        String expected = "peace_459@live.com";
36
+        String actual = checkingAccount.getEmail();
37
+        Assert.assertEquals(expected, actual);
38
+    }
39
+
40
+    @Test
41
+    public void test_Get_Set_Pin() {
42
+        CheckingAccount checkingAccount = new CheckingAccount();
43
+
44
+        checkingAccount.setPin(949428);
45
+        int expected = 949428;
46
+        int actual = checkingAccount.getPin();
47
+        Assert.assertEquals(expected, actual);
48
+    }
49
+
50
+    @Test
51
+    public void test_Get_Balance() {
52
+        CheckingAccount checkingAccount = new CheckingAccount();
53
+
54
+        double actual = checkingAccount.getBalance();
55
+        double expected = 3333.33;
56
+        Assert.assertTrue(expected == actual);
57
+    }
58
+
59
+    @Test
60
+    public void testPay_WriteCheck(){
61
+        CheckingAccount checkingAccount = new CheckingAccount(555.55);
62
+
63
+        double amountToPay = 13.82;
64
+        checkingAccount.pay(amountToPay);
65
+
66
+        Assert.assertEquals(541.73 , 555.55 - amountToPay, 541.73);
67
+    }
68
+
69
+
70
+}

+ 13
- 0
src/test/java/com/zipcodewilmington/bankaccountlab/TestAtm.java Dosyayı Görüntüle

@@ -0,0 +1,13 @@
1
+package com.zipcodewilmington.bankaccountlab;
2
+
3
+import org.junit.Test;
4
+
5
+public class TestAtm {
6
+
7
+    @Test
8
+    public void testGetBalance(){
9
+
10
+
11
+
12
+    }
13
+}