-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDogs_portal.java
44 lines (42 loc) · 1002 Bytes
/
Dogs_portal.java
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
37
38
39
40
41
42
43
44
import java.util.Scanner;
class Dog
{
String name,breed;
public String getBreed()
{
return breed;
}
public void setName(String name)
{
this.name = name;
}
public void setBreed(String breed)
{
this.breed = breed;
}
public void display()
{
String behave;
if(this.getBreed().equals("Labrador"))behave="arrogant";
else behave = "nice";
System.err.println(this.name +" is a "+ this.getBreed()+" which is "+behave);
}
}
public class Dogs_portal {
public static void main(String[] args) {
Scanner s =new Scanner(System.in);
int num = s.nextInt();
Dog d[] = new Dog[num];
String name,breed;
for(int i=0;i<num;i++)
{
name = s.next();
d[i] = new Dog();
d[i].setName(name);
breed = s.next();
d[i].setBreed(breed);
}
for(int i=0;i<num;i++)
d[i].display();
}
}