-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
44 lines (33 loc) · 845 Bytes
/
Copy pathAccount.java
File metadata and controls
44 lines (33 loc) · 845 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
35
36
37
38
39
40
41
42
43
44
package com.test02;
public class Account {
private String account;
private int balance;
private double interestRate;
Account() {
}
Account(String account, int balance, double interestRate) {
this.account = account;
this.balance = balance;
this.interestRate = interestRate;
} // 매개변수로 값 지정
public void setAccount(String account) { // setter
this.account = account;
}
public String getAccount() { // getter
return account;
} // 가지고 있는 값을 리턴
public int getBalance() {
return balance;
}
public double calculateInterest() {
return ((balance * interestRate) / 100);
}
public void deposit(int deposit) {
balance += deposit;
}
public void withdraw(int withdraw) {
if (balance - withdraw >= 0) {
balance -= withdraw;
}
}
}