-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBudget.java
34 lines (29 loc) · 935 Bytes
/
Budget.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
public class Budget{
private double balance = 0.0;
private double budgetLimit = 0.0;
private boolean limit = false;
public Budget(double balance,double budgetLimit){
this.balance = balance;
this.budgetLimit = budgetLimit;
limit = balance > budgetLimit;
}
public String getLimit() {
return limit ? "You are above the Budget Limit" : "You are below the Budget Limit! Enjoy :)"; //simpliefied the code
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getBudgetLimit() {
return budgetLimit;
}
public void setBudgetLimit(double budgetLimit) {
this.budgetLimit = budgetLimit;
}
@Override
public String toString() {
return "Balance: " + balance + ", BudgetLimit: " + budgetLimit;
}
}