Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.44 KB | None | 0 0
  1. public class Main {
  2.     public static void main(String[] args) {
  3.  
  4.         Account bobsAccount = new Account("12345", 0.00, "Bob Brown", "myemail@bob.com",
  5.                 "123456789");
  6.         System.out.println(bobsAccount.getNumber());
  7.         System.out.println(bobsAccount.getBalance());
  8.         System.out.println(bobsAccount.getCustomerName());
  9.         System.out.println(bobsAccount.getCustomerEmailAddres());
  10.         System.out.println(bobsAccount.getCustomerEmailAddres());
  11.  
  12.  
  13.         bobsAccount.withdrawal(100.0);
  14.  
  15.         bobsAccount.deposit(50.0);
  16.         bobsAccount.withdrawal(100.0);
  17.  
  18.         bobsAccount.deposit(51.0);
  19.         bobsAccount.withdrawal(100.0);
  20.  
  21.         Account timsAccount = new Account("Tim", "tim@email.com", "123456");
  22.         System.out.println(timsAccount.getNumber() + " Name " + timsAccount.getCustomerName());
  23.  
  24.  
  25.         VipPerson person1 = new VipPerson();
  26.         System.out.println(person1.getName());
  27.  
  28.         VipPerson person2 = new VipPerson("Bob", 25000.00);
  29.         System.out.println(person2.getName());
  30.  
  31.         VipPerson person3 = new VipPerson("Tim", 150.00, "tim@email.com");
  32.         System.out.println(person3.getName());
  33.         System.out.println(person3.getEmailAddress());
  34.  
  35.     }
  36. }
  37.  
  38. // Person
  39. public class VipPerson {
  40.     private String name;
  41.     private double creditLimit;
  42.     private String emailAddress;
  43.  
  44.     public VipPerson() {
  45.         this("Default name", 50000.00, "default@email.com");
  46.     }
  47.  
  48.     public VipPerson(String name, double creditLimit) {
  49.         this(name, creditLimit, "unknown@email.com");
  50.     }
  51.  
  52.     public VipPerson(String name, double creditLimit, String emailAddress) {
  53.         this.name = name;
  54.         this.creditLimit = creditLimit;
  55.         this.emailAddress = emailAddress;
  56.     }
  57.  
  58.     public String getName() {
  59.         return name;
  60.     }
  61.  
  62.     public double getCreditLimit() {
  63.         return creditLimit;
  64.     }
  65.  
  66.     public String getEmailAddress() {
  67.         return emailAddress;
  68.     }
  69. }
  70.  
  71. //Acc
  72.  
  73. public class Account {
  74.     private String number;
  75.     private double balance;
  76.     private String customerName;
  77.     private String customerEmailAddres;
  78.     private String customerPhoneNumber;
  79.  
  80.     public Account() {
  81.         System.out.println("Empty constructor called");
  82.     }
  83.  
  84.     public Account(String number, double balance, String customerName, String customerEmailAddres,
  85.                    String customerPhoneNumber) {
  86.         this.number = number;
  87.         this.balance = balance;
  88.         this.customerName = customerName;
  89.         this.customerEmailAddres = customerEmailAddres;
  90.         this.customerPhoneNumber = customerPhoneNumber;
  91.         System.out.println("Account constructor with parameters called");
  92.     }
  93.  
  94.     public Account(String customerName, String customerEmailAddres, String customerPhoneNumber) {
  95.         this("99999", 100.55, customerName, customerEmailAddres, customerPhoneNumber);
  96.     }
  97.  
  98.     public void deposit(double depositAmount) {
  99.         this.balance += depositAmount;
  100.         System.out.println("Deposit of " + depositAmount + " made. New balance is " + this.balance);
  101.     }
  102.  
  103.     public void withdrawal(double withdrawalAmount) {
  104.         if(this.balance - withdrawalAmount <=0) {
  105.             System.out.println("Only " + this.balance + " available. Withdrawal not processed");
  106.         } else {
  107.             this.balance -= withdrawalAmount;
  108.             System.out.println("Withdrawal of " + withdrawalAmount + " processed. Remaining is = " + this.balance);
  109.         }
  110.     }
  111.  
  112.     public String getNumber() {
  113.         return number;
  114.     }
  115.  
  116.     public void setNumber(String number) {
  117.         this.number = number;
  118.     }
  119.  
  120.     public double getBalance() {
  121.         return balance;
  122.     }
  123.  
  124.     public void setBalance(double balance) {
  125.         this.balance = balance;
  126.     }
  127.  
  128.     public String getCustomerName() {
  129.         return customerName;
  130.     }
  131.  
  132.     public void setCustomerName(String customerName) {
  133.         this.customerName = customerName;
  134.     }
  135.  
  136.     public String getCustomerEmailAddres() {
  137.         return customerEmailAddres;
  138.     }
  139.  
  140.     public void setCustomerEmailAddres(String customerEmailAddres) {
  141.         this.customerEmailAddres = customerEmailAddres;
  142.     }
  143.  
  144.     public String getCustomerPhoneNumber() {
  145.         return customerPhoneNumber;
  146.     }
  147.  
  148.     public void setCustomerPhoneNumber(String customerPhoneNumber) {
  149.         this.customerPhoneNumber = customerPhoneNumber;
  150.     }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement