blob: 82875be7d7e17bb719f7fdc63e4d1691141a58e2 (
plain)
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
|
public class Account {
/* Declaring fields - represent state */
int accountNumber;
double balance;
// No argument constructor
public Account() {
System.out.println("No argument constructor");
}
// A constructor with an argument
public Account(double initialBalance) {
balance = initialBalance;
System.out.println("Argument constructor");
}
/* Declaring methods - represent operations */
public void withdraw(double amount) {
if (balance >= amount) {
balance = balance - amount;
}
}
// Overloaded method
public void deposit(double amount) {
balance += amount;
}
// Overloaded method
public void deposit(int amount) {
balance += amount;
}
public double getBalance() {
return balance;
}
// public int getBalance() {
// return 1;
// }
}
|