Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. package Collections.People;
  2.  
  3. public class Human {
  4.     private String name;
  5.     private int age;
  6.     private String phone;
  7.  
  8.     public String getName() {
  9.         return name;
  10.     }
  11.  
  12.     public void setName(String name) {
  13.         this.name = name;
  14.     }
  15.  
  16.     public int getAge() {
  17.         return age;
  18.     }
  19.  
  20.     public void setAge(int age) {
  21.         this.age = age;
  22.     }
  23.  
  24.     public String getPhone() {
  25.         return phone;
  26.     }
  27.  
  28.     public void setPhone(String phone) {
  29.         this.phone = phone;
  30.     }
  31.  
  32.     public static String whoIsWho(Object o) {
  33.         if (o.getClass().toString().contains("Teacher")) {
  34.             return "Hello Teacher!";
  35.         } else if (o.getClass().toString().contains("Student")) {
  36.             return "Hello Student!";
  37.         } else if (o.getClass().toString().contains("Human")) {
  38.             return "Hello Human!";
  39.         } else return null;
  40.     }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement