├── .classpath
├── .project
├── .settings
├── org.eclipse.core.resources.prefs
└── org.eclipse.jdt.core.prefs
├── bin
├── Account.class
└── Bank.class
└── src
├── Account.java
└── Bank.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Bank-Java
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/Account.java=UTF-8
3 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=15
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
13 | org.eclipse.jdt.core.compiler.release=enabled
14 | org.eclipse.jdt.core.compiler.source=15
15 |
--------------------------------------------------------------------------------
/bin/Account.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmadpanah/Java-Bank-Advance-Programming2/5f21811858f8cf5471929714a924c8a9a0d19440/bin/Account.class
--------------------------------------------------------------------------------
/bin/Bank.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahmadpanah/Java-Bank-Advance-Programming2/5f21811858f8cf5471929714a924c8a9a0d19440/bin/Bank.class
--------------------------------------------------------------------------------
/src/Account.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 |
3 | public class Account {
4 |
5 | // Class Variable
6 | int balance;
7 | int prevTransaction;
8 | String customerName;
9 | String customerId;
10 |
11 | // Class Constructor
12 | Account(String cname, String cid) {
13 | customerName = cname;
14 | customerId = cid;
15 | }
16 |
17 | void deposit(int amount) {
18 | if (amount != 0) {
19 | balance = balance + amount;
20 | prevTransaction = amount;
21 | }
22 | }
23 |
24 | void withdraw(int amount) {
25 | if (amount != 0) {
26 | balance = balance - amount;
27 | prevTransaction = -amount;
28 | }
29 | }
30 |
31 | void getPrevTransaction() {
32 | if (prevTransaction > 0) {
33 | System.out.println("Deposited: " + prevTransaction);
34 | } else if (prevTransaction <0) {
35 | System.out.println("Withdrawn: " + Math.abs(prevTransaction));
36 | }
37 | }
38 |
39 | void showMenu() {
40 | char option = '\0';
41 | Scanner scanner = new Scanner(System.in);
42 | System.out.println("Welcome " + customerName);
43 | System.out.println("Your id is: " + customerId);
44 | System.out.println();
45 | System.out.println("What would you like to do?");
46 | System.out.println("A. Check Your Balance");
47 | System.out.println("B. make a Deposit");
48 | System.out.println("C. make a Withdraw");
49 | System.out.println("D. Show Previous Tranaction");
50 | System.out.println("E. Exit");
51 |
52 | do {
53 | System.out.println("");
54 | System.out.println("Please Enter an option:");
55 | char option1 = scanner.next().charAt(0);
56 | option = Character.toUpperCase(option1);
57 | System.out.println();
58 |
59 | switch(option) {
60 | case 'A':
61 | System.out.println("=============");
62 | System.out.println("Balance = $" + balance);
63 | System.out.println("=============");
64 | break;
65 | case 'B':
66 | System.out.println("Enter an amount to deposit: ");
67 | int amount = scanner.nextInt();
68 | deposit(amount);
69 | System.out.println();
70 | break;
71 | case 'C':
72 | System.out.println("Enter an amount to Withdraw: ");
73 | int amount2 = scanner.nextInt();
74 | withdraw(amount2);
75 | break;
76 | case 'D':
77 | getPrevTransaction();
78 | break;
79 | case 'E':
80 | System.out.println("==========");
81 | break;
82 | default:
83 | System.out.println("Error: invalid option. Please Enter a,b,c,d");
84 | break;
85 | }
86 | } while (option != 'E');
87 |
88 |
89 | System.out.println("Thank you for banking with us ♥ ");
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/Bank.java:
--------------------------------------------------------------------------------
1 |
2 | public class Bank {
3 |
4 | public static void main(String[] args) {
5 | Account hossein = new Account("Hossein Ahmadpanah" , "IR51498481");
6 | // hossein.showMenu();
7 |
8 | Account mina = new Account("Mina Hashemi" , "IR519841261");
9 | mina.showMenu();
10 |
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------