class BankAccount {
constructor(name, accountNumber, balance) {
this.name = name;
this.accountNumber = accountNumber;
this.balance = balance;
}
deposit(amount) {
if (amount > 0) {
this.balance += amount;
} else {
throw new Error("Deposit amount must be positive.");
}
}
withdraw(amount) {
if (amount > 0) {
if (amount <= this.balance) {
this.balance -= amount;
} else {
throw new Error("Insufficient funds for this withdrawal.");
}
} else {
throw new Error("Withdrawal amount must be positive.");
}
}
getBalance() {
return this.balance;
}
getAccountDetails() {
return "Account Holder: " +this.name;
}
}
// Example usage:
const account = new BankAccount("YUSUPH MDOE", "40052258006", 1500.0);
account.deposit(200.0);
console.log(account.getBalance());
account.withdraw(100.0);
console.log(account.getBalance());
console.log(account.getAccountDetails());