Skip to content

Commit 80ccf0d

Browse files
committed
6번째 문제
1 parent 462120f commit 80ccf0d

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

bin/homework/Account.class

-100 Bytes
Binary file not shown.

src/homework/AccountTest.java

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,14 @@ public Account(String acc_Num, int deposit, int withdraw, int money) {
3333
this.money = money;
3434
}
3535

36-
public void printResult() {
37-
System.out.println("계좌번호 " + getAcc_Num() + "의 현재 잔액 : " + money);
38-
}
39-
4036
public String getAcc_Num() {
4137
return acc_Num;
4238
}
4339

44-
// 계좌번호 입력
4540
public void setAcc_Num() {
46-
// this.acc_Num = acc_Num;
41+
bar();
4742
System.out.print("계좌번호를 입력하세요 : ");
48-
acc_Num = sc.nextLine();
43+
this.acc_Num = sc.nextLine();
4944
printResult();
5045
empty();
5146
}
@@ -54,10 +49,6 @@ public int getMoney() {
5449
return money;
5550
}
5651

57-
public void setMoney(int money) {
58-
this.money = money;
59-
}
60-
6152
public void deposit() {
6253
System.out.print("입금할 금액 : ");
6354
int d_Mon = sc.nextInt();
@@ -71,11 +62,10 @@ public void withdraw() {
7162
int w_Mon = sc.nextInt();
7263
if (money < w_Mon) {
7364
System.out.println("출금하려는 계좌의 잔액이 부족하여 출금이 불가능합니다");
74-
System.out.print("출금할 금액 : ");
75-
w_Mon = sc.nextInt();
7665
} else {
7766
money -= w_Mon;
7867
}
68+
7969
printResult();
8070
}
8171

@@ -86,29 +76,59 @@ public void empty() {
8676
public void bar() {
8777
System.out.println("=======================================");
8878
}
79+
80+
public void printResult() {
81+
System.out.println("계좌번호 " + getAcc_Num() + "의 현재 잔액 : " + money);
82+
}
8983
}
9084

9185
public class AccountTest {
9286

9387
public static void main(String[] args) {
94-
Account a1 = new Account();
88+
Scanner sc = new Scanner(System.in);
89+
90+
String bar[] = { "\t계좌번호 \t\t", " 잔액" };
91+
// 계좌번호 리스트
92+
String acc_Num[] = new String[3];
93+
// 잔액 리스트
94+
int balance[] = new int[3];
95+
9596
// 고객1
96-
a1.bar();
97+
Account a1 = new Account();
9798
a1.setAcc_Num();
9899
a1.deposit();
99100
a1.withdraw();
100-
// 고객 2
101+
acc_Num[0] = a1.getAcc_Num();
102+
balance[0] = a1.getMoney();
103+
104+
// 고객2
101105
Account a2 = new Account();
102-
a2.bar();
103106
a2.setAcc_Num();
104107
a2.deposit();
105108
a2.withdraw();
109+
acc_Num[1] = a2.getAcc_Num();
110+
balance[1] = a2.getMoney();
111+
106112
// 고객3
107113
Account a3 = new Account();
108-
a3.bar();
109114
a3.setAcc_Num();
110115
a3.deposit();
111116
a3.withdraw();
117+
acc_Num[2] = a3.getAcc_Num();
118+
balance[2] = a3.getMoney();
119+
120+
a1.bar();
121+
for (int i = 0; i < bar.length; i++) {
122+
System.out.print(bar[i]);
123+
}
124+
a1.empty();
125+
a1.bar();
126+
127+
// 반복문
128+
for (int i = 0; i < 3; i++) {
129+
System.out.println("\t" + acc_Num[i] + "\t\t" + balance[i]);
130+
}
131+
a1.bar();
112132
}
113133

114134
}

0 commit comments

Comments
 (0)