Repository navigation
Expand file tree
/
Copy pathAccount.java
More file actions
56 lines (54 loc) · 1.5 KB
/
Copy pathAccount.java
File metadata and controls
56 lines (54 loc) · 1.5 KB
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
48
49
50
51
52
53
54
55
56
/*
* Filename: Account.java
*
* Description: 13.18 - Represents a bank account
*
* Created: 05/12/15 03:55:53
* Revision: none
*
* @Author: Siidney Watson - [email protected]
* @Version: 1.0
*
* =====================================================================================
*/
public class Account{
private int accountNumber;
private int pin;
private double availableBalance;
private double totalBalance;
// CONSTRUCTOR
// initialise attributes
public Account(int theAccountNumber, int thePIN,
double theAvailableBalance, double theTotalBalance){
accountNumber = theAccountNumber;
pin = thePIN;
availableBalance = theAvailableBalance;
totalBalance = theTotalBalance;
}
// determines whether a user-specified PIN matches PIN in Account
public boolean validatePIN(int userPIN){
if(userPIN == pin)
return true;
else
return false;
}
// GETTERS
public double getAvailableBalance(){
return availableBalance;
}
public double getTotalBalance(){
return totalBalance;
}
public int getAccountNumber(){
return accountNumber;
}
// credits an amount to the account
public void credit(double amount){
totalBalance += amount;
}
// debits an amount from the account
public void debit(double amount){
availableBalance -= amount;
totalBalance -= amount;
}
}