-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYourFirstMoneyTransfer.java
47 lines (36 loc) · 999 Bytes
/
YourFirstMoneyTransfer.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
35
36
37
38
39
40
41
42
43
44
45
46
47
public class Accounts {
public static void main(String[] args) {
Account mattsAccount = new Account("Matt's account", 1000.00);
Account myAccount = new Account("My account", 0.00);
mattsAccount.withdrawal(100.00);
myAccount.deposit(100.00);
System.out.println(mattsAccount);
System.out.println(myAccount);
// Code in Account.Java should not be touched!
// write your code here
}
}
/*
* Do not touch this!
*/
public class Account {
private double balance;
private String owner;
public Account(String owner, double balance) {
this.balance = balance;
this.owner = owner;
}
public void deposit(double amount) {
balance += amount;
}
public void withdrawal(double amount) {
balance -= amount;
}
public double balance() {
return balance;
}
@Override
public String toString() {
return owner + " balance: " + balance;
}
}