-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAccount.java
More file actions
39 lines (32 loc) · 796 Bytes
/
Account.java
File metadata and controls
39 lines (32 loc) · 796 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
package com.codefortomorrow.intermediate.chapter12.practice;
/*
Create a UML diagram for the Account class.
*/
@SuppressWarnings("unused")
public class Account {
private String name;
private long number;
private double balance;
public Account() {
name = "";
number = 0;
balance = 0;
}
public Account(String name, long number, double balance) {
this.name = name;
this.number = number;
this.balance = balance;
}
public void deposit(double amount) {
if (amount > 0) {
balance += amount;
}
}
public boolean withdraw(double amount) {
if (amount > 0 && amount <= balance) {
balance -= amount;
return true;
}
return false;
}
}