Skip to content

Instantly share code, notes, and snippets.

@0ryant
Created August 13, 2019 11:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 0ryant/ea15d36c713f444eddd36c97e0d4fea6 to your computer and use it in GitHub Desktop.
Save 0ryant/ea15d36c713f444eddd36c97e0d4fea6 to your computer and use it in GitHub Desktop.
Java - Coding Challenge - Bank Account
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);
}
}
}
@0ryant
Copy link
Author

0ryant commented Aug 13, 2019

public class VIPCustomer {

    // Params
    private String name;
    private double creditLimit;
    private String emailAddress;

    // Constructors
    public VIPCustomer(){
        this("Default Name",0,"Default Email Address");
    }
    public VIPCustomer(String name,String emailAddress){
        this(name,0.0,"Default Email Address");
    }
    public VIPCustomer(String name, double creditLimit, String emailAddress) {
        this.name = name;
        this.creditLimit = creditLimit;
        this.emailAddress = emailAddress;
    }

    // Getters
    public String getName() {
        return name;
    }
    public double getCreditLimit() {
        return creditLimit;
    }
    public String getEmailAddress() {
        return emailAddress;
    }


}

@jcteam11
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment