-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
63 lines (49 loc) · 1.47 KB
/
Account.java
File metadata and controls
63 lines (49 loc) · 1.47 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
import java.util.Date;
class Account {
private int id;
private double balance;
private static double annualInterestRate = 0.0;
private Date dateCreated;
public Account(int accountId, double startBalance) {
this.id = accountId;
this.balance = startBalance;
this.dateCreated = new Date();
}
public int getId() {
return this.id;
}
public double getBalance() {
return this.balance;
}
public static double getAnnualInterestRate() {
return annualInterestRate;
}
public static void setAnnualInterestRate(double rate) {
annualInterestRate = rate;
}
public Date getDateCreated() {
return this.dateCreated;
}
public double getMonthlyInterestRate() {
return annualInterestRate / (double)12.0F;
}
public double withdraw(double amount) {
if (amount > this.balance) {
amount = this.balance;
}
this.balance -= amount;
return amount;
}
public void deposit(double amount) {
this.balance += amount;
}
@Override
public String toString() {
return "Account" + "id= " + id + "balance" + String.format("%.2f", balance) +
"annualInterestRate= " + annualInterestRate + "dateCreated= " + dateCreated;
}
}