From 965838bad9cc3edf5ea3d73e9c901bb892ec5f9e Mon Sep 17 00:00:00 2001 From: pankaj-babban <124651729+pankaj-babban@users.noreply.github.com> Date: Wed, 8 Mar 2023 12:27:15 +0530 Subject: [PATCH] Java Training Person Class --- Constructor/Account.java | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Constructor/Account.java diff --git a/Constructor/Account.java b/Constructor/Account.java new file mode 100644 index 0000000..174033a --- /dev/null +++ b/Constructor/Account.java @@ -0,0 +1,82 @@ +package Constructor; +public class Account { + + private String number; + private double balance; + private String customerName; + private String customerEmail; + private String customerPhone; + + public Account() { + System.out.println("Empty constructor called"); + } + + public Account(String number, double balance, String customerName, String email, + String phone) { + System.out.println("Account constructor with parameters called"); + this.number = number; + this.balance = balance; + this.customerName = customerName; + customerEmail = email; + customerPhone = phone; + } + + public void depositFunds(double depositAmount) { + + balance += depositAmount; + System.out.println("Deposit of $" + depositAmount + " made. New balance is $" + + balance); + } + + public void withdrawFunds(double withdrawalAmount) { + + if (balance - withdrawalAmount < 0) { + System.out.println("Insufficient Funds! You only have $" + balance + + " in your account."); + } else { + balance -= withdrawalAmount; + System.out.println("Withdrawal of $" + withdrawalAmount + + " processed, Remaining balance = $" + balance); + } + } + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public double getBalance() { + return balance; + } + + public void setBalance(double balance) { + this.balance = balance; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getCustomerEmail() { + return customerEmail; + } + + public void setCustomerEmail(String customerEmail) { + this.customerEmail = customerEmail; + } + + public String getCustomerPhone() { + return customerPhone; + } + + public void setCustomerPhone(String customerPhone) { + this.customerPhone = customerPhone; + } +}