Untitled
unknown
plain_text
4 years ago
2.1 kB
8
Indexable
package course;
public class BankAccount {
private int number;
private double balance;
private String customerName;
private String customerEmail;
private int phoneNumber;
//CONSTRUCTORS
public BankAccount() {
this(223344,100.00,"Default name","Default e-mail adress",000);
System.out.println("Empty constructor created.");
}
public BankAccount(int number, double balance, String customerName, String customerEmail, int phoneNumber) {
System.out.println("Account constructor with parameters called.");
this.number = number;
this.balance = balance;
this.customerName = customerName;
this.customerEmail = customerEmail;
this.phoneNumber = phoneNumber;
}
//FUNCTIONALITIES
public void depositFunds(int amount) {
this.balance += amount;
}
public void withdrawFunds(int amount) {
if(amount > this.balance) {
System.out.println("Not enough money.");
} else {
this.balance -= amount;
System.out.println(amount + "$ successfully withdrawal.\nActual balance: " + this.balance);
}
}
//GETTERS
public int getNumber() {
return this.number;
}
public double getBalance() {
return this.balance;
}
public String getCustomerName() {
return this.customerName;
}
public String getCustomerEmail() {
return this.customerEmail;
}
public int getPhoneNumber() {
return this.phoneNumber;
}
//SETTERS
public void setNumber(int number) {
this.number = number;
}
public void setBalance(double balance) {
this.balance = balance;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public void setCustomerEmail(String customerEmail) {
this.customerEmail = customerEmail;
}
public void setPhoneNumber(int phoneNumber) {
this.phoneNumber = phoneNumber;
}
}Editor is loading...