-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBank.java
38 lines (32 loc) · 1.08 KB
/
Bank.java
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
35
36
37
38
public class Bank {
private int account;
protected final int MAX_ACCOUNT_VALUE = 2000;
protected final int MIN_ACCOUNT_VALUE = 1;
public int getAccount() {
return account;
}
public void setAccount(int account) {
if (account < 1)
throw new IllegalArgumentException("Incorrect account value!");
this.account = account;
}
public Bank(int account) {
if (account < 1)
throw new IllegalArgumentException("Incorrect account value!");
this.account = account;
}
public void inc(){
System.out.println("Inc start: " + account);
for(; account < MAX_ACCOUNT_VALUE; account += 2){
System.out.println("inc: " + account);
}
System.out.println("Inc finish: " + account);
}
public void dec(){
System.out.println("Dec start: " + account);
for(; account > MIN_ACCOUNT_VALUE; account--){
System.out.println("dec: " + account);
}
System.out.println("Dec finish: " + account);
}
}