-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankAccount-1.java
More file actions
72 lines (56 loc) · 1.58 KB
/
BankAccount-1.java
File metadata and controls
72 lines (56 loc) · 1.58 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
//Program Name: BankAccount.java
//Author: Joshua Decker
//Class: CSC110AB
//Date Written: 4/11/2022
//Brief Description: BankAccount.java contains the constructor method, accessor/mutator methods, and a method to changes balance to a string. Updated with new parameters for ch10
package ch10;
import java.text.NumberFormat;
public class BankAccount {
private static int count = 0;
private double balance;
private int acctNumber;
private String name;
private NumberFormat nFmt = NumberFormat.getCurrencyInstance();
public BankAccount() {
acctNumber = 0;
name = "Unknown";
balance = 0.00;
count++;
}
public BankAccount(int acctNo, double userBalance,String userName) {
acctNumber = acctNo;
balance = userBalance;
name = userName;
count++;
}
public void setAcctNumber(int acctNo) {
acctNumber = acctNo;
}
public void setName(String userName) {
name = userName;
}
public int getAcctNumber() {
return acctNumber;
}
public double getBalance() {
return balance;
}
public String getName() {
return name;
}
public static int getCount() {
return count;
}
public void deposit(double userDeposit) {
balance += userDeposit;
}
public void withdraw(double userWithdraw) {
balance -= userWithdraw;
}
public void withdraw(double amount, double fee) {
balance -= (amount + fee);
}
public String toString() {
return ("acctNumber: " + acctNumber + " balance : " + nFmt.format(balance) + " name : " + name );
}
}