Advertisement
Braber01

Ben Raber

Sep 24th, 2010
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. public abstract class Person
  2. {  
  3.     protected String first,last,email; 
  4.    
  5.     public Person()
  6.     {
  7.         setFirst("");
  8.         setLast("");
  9.         setEmail("");
  10.     }
  11.     public Person(String first,String last,String email)
  12.     {
  13.         setFirst(first);
  14.         setLast(last);
  15.         setEmail(email);
  16.     }
  17.     public abstract String getDisplayText();
  18.     public String getFirst(){return this.first;}
  19.     public void setFirst(String first){this.first=first;}
  20.     public String getLast(){return this.last;}
  21.     public void setLast(String last){this.last=last;}
  22.     public String getEmail(){return this.email;}
  23.     public void setEmail(String email){this.email=email;}
  24.  
  25.     @Override
  26.     public String toString()
  27.     {
  28.         String msg = "Name: " + this.getFirst() + this.getLast() + "\n" +
  29.             "Email: " + this.getEmail();
  30.         return msg;
  31.     }
  32.  
  33. }//End Class
  34. class Customer extends Person
  35. {
  36.     private String num;
  37.    
  38.     public Customer()
  39.     {
  40.         super();
  41.         setNum("");
  42.     }
  43.     public Customer(String first,String last,String email,String num)
  44.     {
  45.         super(first,last,email);
  46.         setNum(num);
  47.     }
  48.     public String getNum(){return this.num;}
  49.     public void setNum(String num){this.num=num;}
  50.  
  51.     @Override
  52.     public String toString()
  53.     {
  54.         String msg="Name: " + this.getFirst() + this.getLast() + "\n" +
  55.             "Email :" + this.getEmail() + "\n" +
  56.             "Customer Number: " + this.getNum();
  57.         return msg;
  58.     }
  59.  
  60.     @Override
  61.     public String getDisplayText()
  62.     {
  63.         return this.toString();
  64.     }
  65. }//end Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement