-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
36 lines (28 loc) · 1.02 KB
/
Solution.java
File metadata and controls
36 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.javarush.task.task12.task1205;
//So when he had washed their feet, put his outer garment back on,
//and sat down again, he said to them, "Do you know what I have done to you? (John 13:12)
/*
Определимся с животным
*/
public class Solution {
public static void main(String[] args) {
System.out.println(getObjectType(new Cow()));
System.out.println(getObjectType(new Dog()));
System.out.println(getObjectType(new Whale()));
System.out.println(getObjectType(new Pig()));
}
public static String getObjectType(Object o) {
if (o instanceof Cow) {return "Корова";}//Напишите тут ваше решение
else if (o instanceof Whale) {return "Кит";}
else if (o instanceof Dog) {return "Собака";}
else return "Неизвестное животное";
}
public static class Cow {
}
public static class Dog {
}
public static class Whale {
}
public static class Pig {
}
}