Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Collections.People;
- public class Human {
- private String name;
- private int age;
- private String phone;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getAge() {
- return age;
- }
- public void setAge(int age) {
- this.age = age;
- }
- public String getPhone() {
- return phone;
- }
- public void setPhone(String phone) {
- this.phone = phone;
- }
- public static String whoIsWho(Object o) {
- if (o.getClass().toString().contains("Teacher")) {
- return "Hello Teacher!";
- } else if (o.getClass().toString().contains("Student")) {
- return "Hello Student!";
- } else if (o.getClass().toString().contains("Human")) {
- return "Hello Human!";
- } else return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement