Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BankAccount {
- // Params
- private String accountNumber;
- private double balance;
- private String customerName;
- private String emailAddress;
- private String phoneNumber;
- // Constructors
- public BankAccount(){
- this("Default Account Number",0.0,"Default Name",
- "Default Email","Default Phone");
- }
- public BankAccount(String accountNumber,double balance,String customerName, String emailAddress, String phoneNumber){
- this.accountNumber = accountNumber;
- this.balance = balance;
- this.customerName = customerName;
- this.emailAddress = emailAddress;
- this.phoneNumber = phoneNumber;
- }
- public BankAccount(String customerName, String emailAddress, String phoneNumber) {
- this("Default Account Number",0.0,customerName,emailAddress,phoneNumber);
- this.customerName = customerName;
- this.emailAddress = emailAddress;
- this.phoneNumber = phoneNumber;
- }
- // Getters
- public String getAccountNumber(){
- return accountNumber;
- }
- public double getBalance(){
- return balance;
- }
- public String getCustomerName(){
- return customerName;
- }
- public String getEmailAddress(){
- return emailAddress;
- }
- public String getPhoneNumber(){
- return phoneNumber;
- }
- // Setters
- public void setAccountNumber(String accountNumber){
- this.accountNumber=accountNumber;
- }
- public void setBalance(double balance) {
- this.balance = balance;
- }
- public void setCustomerName(String customerName) {
- this.customerName = customerName;
- }
- public void setEmailAddress(String emailAddress) {
- this.emailAddress = emailAddress;
- }
- public void setPhoneNumber(String phoneNumber) {
- this.phoneNumber = phoneNumber;
- }
- // Methods
- public void depositFunds(double deposit){
- if (deposit <0){
- System.out.println("Deposit must be greater than 0!");
- } else {
- this.balance+=deposit;
- System.out.println("New Balance is "+this.balance);
- }
- }
- public void withdrawFunds(double withdraw){
- if (withdraw>this.balance){
- System.out.println("Insufficient Funds, "+this.balance+" available but "+withdraw+" was requested!");
- } else {
- this.balance-=withdraw;
- System.out.println("New Balance is "+this.balance);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement