-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
47 lines (35 loc) · 952 Bytes
/
Account.java
File metadata and controls
47 lines (35 loc) · 952 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
40
41
42
43
44
45
46
47
//main account, checkings and savings inherit from this class
public class Account {
private int accNum;
private double balance;
public Account(int aC, double b){
accNum=aC;
balance=b;
}
public Account(){
accNum=0;
balance=0.0;
}
public int getaccNum(){
return accNum;
}
public double getBalance(){
return balance;
}
public void setBalance(double newBalance){
balance = newBalance;
}
public void print(){
System.out.printf("Balance = %f, Account Number %d%n", balance, accNum);
}
//deposit function
public void deposit(double amount){
if(amount>0)
balance+= amount;
}
//withdraw function
public void withdraw(double amount){
if(amount>0 && amount<= balance)
balance-=amount;
}
}