Hellboyandso

Customer.java

Dec 15th, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. package domain;
  2.  
  3. public class Customer extends Person {
  4.     private String custNbr;
  5.  
  6.     public Customer(String custNbr, String name, String surname, Address address) {
  7.         super(name, surname, address);
  8.         this.setCustNbr(custNbr);
  9.     }
  10.  
  11.     public String getCustNbr() {
  12.         return custNbr;
  13.     }
  14.  
  15.     private void setCustNbr(String custNbr) {
  16.         this.custNbr = custNbr;
  17.     }
  18.  
  19.     @Override
  20.     public boolean equals(Object o) {
  21.         if (this == o) return true;
  22.         if (o == null || getClass() != o.getClass()) return false;
  23.         Customer customer = (Customer) o;
  24.         return custNbr.equals(customer.custNbr);
  25.     }
  26.  
  27.     @Override
  28.     public int hashCode() {
  29.         return custNbr.hashCode();
  30.     }
  31.    
  32.     @Override
  33.     public String toString() {
  34.         return "CustNbr: " + custNbr + " " + super.toString();
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment