-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
113 lines (89 loc) · 2.67 KB
/
Account.java
File metadata and controls
113 lines (89 loc) · 2.67 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Account.java
// Represents a bank account
public class Account
{
private int accountNumber; // account number
private int pin; // PIN for authentication
private double availableBalance; // funds available for withdrawal
private double totalBalance; // funds available + pending deposits
private int admin;
private String username;
// Account constructor initializes attributes
public Account(String Username, int theAccountNumber, int thePIN,
double theAvailableBalance, double theTotalBalance, int isadmin)
{
setUsername(Username);
setAccountNumber(theAccountNumber);
setPin(thePIN);
setAvailableBalance(theAvailableBalance);
setTotalBalance(theTotalBalance);
setAdmin(isadmin);
} // end Account constructor
// determines whether a user-specified PIN matches PIN in Account
public boolean validatePIN(int userPIN)
{
if (userPIN == getPin())
return true;
else
return false;
} // end method validatePIN
// returns available balance
public double getAvailableBalance()
{
return availableBalance;
} // end getAvailableBalance
// returns the total balance
public double getTotalBalance()
{
return totalBalance;
} // end method getTotalBalance
// credits an amount to the account
public void credit(double amount)
{
setTotalBalance(getTotalBalance() + amount); // add to total balance
} // end method credit
// debits an amount from the account
public void debit(double amount)
{
setAvailableBalance(getAvailableBalance() - amount); // subtract from available balance
setTotalBalance(getTotalBalance() - amount); // subtract from total balance
} // end method debit
// returns account number
public int getAccountNumber()
{
return accountNumber;
} // end method getAccountNumber
public int getISadmin()
{
return getAdmin();
}
public int GetPin(){
return getPin();
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public void setAccountNumber(int accountNumber) {
this.accountNumber = accountNumber;
}
public int getPin() {
return pin;
}
public void setPin(int pin) {
this.pin = pin;
}
public void setAvailableBalance(double availableBalance) {
this.availableBalance = availableBalance;
}
public void setTotalBalance(double totalBalance) {
this.totalBalance = totalBalance;
}
public int getAdmin() {
return admin;
}
public void setAdmin(int admin) {
this.admin = admin;
}