Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- Account bobsAccount = new Account("12345", 0.00, "Bob Brown", "myemail@bob.com",
- "123456789");
- System.out.println(bobsAccount.getNumber());
- System.out.println(bobsAccount.getBalance());
- System.out.println(bobsAccount.getCustomerName());
- System.out.println(bobsAccount.getCustomerEmailAddres());
- System.out.println(bobsAccount.getCustomerEmailAddres());
- bobsAccount.withdrawal(100.0);
- bobsAccount.deposit(50.0);
- bobsAccount.withdrawal(100.0);
- bobsAccount.deposit(51.0);
- bobsAccount.withdrawal(100.0);
- Account timsAccount = new Account("Tim", "tim@email.com", "123456");
- System.out.println(timsAccount.getNumber() + " Name " + timsAccount.getCustomerName());
- VipPerson person1 = new VipPerson();
- System.out.println(person1.getName());
- VipPerson person2 = new VipPerson("Bob", 25000.00);
- System.out.println(person2.getName());
- VipPerson person3 = new VipPerson("Tim", 150.00, "tim@email.com");
- System.out.println(person3.getName());
- System.out.println(person3.getEmailAddress());
- }
- }
- // Person
- public class VipPerson {
- private String name;
- private double creditLimit;
- private String emailAddress;
- public VipPerson() {
- this("Default name", 50000.00, "default@email.com");
- }
- public VipPerson(String name, double creditLimit) {
- this(name, creditLimit, "unknown@email.com");
- }
- public VipPerson(String name, double creditLimit, String emailAddress) {
- this.name = name;
- this.creditLimit = creditLimit;
- this.emailAddress = emailAddress;
- }
- public String getName() {
- return name;
- }
- public double getCreditLimit() {
- return creditLimit;
- }
- public String getEmailAddress() {
- return emailAddress;
- }
- }
- //Acc
- public class Account {
- private String number;
- private double balance;
- private String customerName;
- private String customerEmailAddres;
- private String customerPhoneNumber;
- public Account() {
- System.out.println("Empty constructor called");
- }
- public Account(String number, double balance, String customerName, String customerEmailAddres,
- String customerPhoneNumber) {
- this.number = number;
- this.balance = balance;
- this.customerName = customerName;
- this.customerEmailAddres = customerEmailAddres;
- this.customerPhoneNumber = customerPhoneNumber;
- System.out.println("Account constructor with parameters called");
- }
- public Account(String customerName, String customerEmailAddres, String customerPhoneNumber) {
- this("99999", 100.55, customerName, customerEmailAddres, customerPhoneNumber);
- }
- public void deposit(double depositAmount) {
- this.balance += depositAmount;
- System.out.println("Deposit of " + depositAmount + " made. New balance is " + this.balance);
- }
- public void withdrawal(double withdrawalAmount) {
- if(this.balance - withdrawalAmount <=0) {
- System.out.println("Only " + this.balance + " available. Withdrawal not processed");
- } else {
- this.balance -= withdrawalAmount;
- System.out.println("Withdrawal of " + withdrawalAmount + " processed. Remaining is = " + this.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 getCustomerEmailAddres() {
- return customerEmailAddres;
- }
- public void setCustomerEmailAddres(String customerEmailAddres) {
- this.customerEmailAddres = customerEmailAddres;
- }
- public String getCustomerPhoneNumber() {
- return customerPhoneNumber;
- }
- public void setCustomerPhoneNumber(String customerPhoneNumber) {
- this.customerPhoneNumber = customerPhoneNumber;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement