-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
34 lines (27 loc) · 967 Bytes
/
Account.java
File metadata and controls
34 lines (27 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public class Account {
public static final int MIN_BALANCE = 0;
public static final int MAX_BALANCE = 1000000;
private int balance;
public int getBalance() {
return balance;
}
public void setBalance(int balance) {
if(balance<Account.MIN_BALANCE || balance>Account.MAX_BALANCE) {
return;
}
this.balance = balance;
}
}
class AccountExample {
public static void main(String[] args) {
Account account = new Account();
account.setBalance(10000);
System.out.println("현재 잔고: " + account.getBalance());
account.setBalance(-100);
System.out.println("현재 잔고: " + account.getBalance());
account.setBalance(2000000);
System.out.println("현재 잔고: " + account.getBalance());
account.setBalance(300000);
System.out.println("현재 잔고: " + account.getBalance());
}
}