-
Notifications
You must be signed in to change notification settings - Fork 153
/
Copy pathAccount.java
130 lines (104 loc) · 3.76 KB
/
Account.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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// 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;
}
} // end class Account
/**************************************************************************
* (C) Copyright 1992-2014 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
*************************************************************************/