-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDog.java
59 lines (47 loc) · 1.04 KB
/
Dog.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
45
46
47
48
49
50
51
52
53
54
55
56
// Class Declaration
public class Dog {
// Instance Variables
String name;
String breed;
int age;
String color;
// Constructor Decalaration of Class
public Dog(String name , String breed, int age , String color)
{
this.name = name;
this.breed = breed;
this.age = age;
this.color = color;
}
//method 1
public String getName()
{
return name;
}
//method 2
public String getBreed()
{
return breed;
}
//method 3
public int getAge()
{
return age;
}
//method 4
public String getColor()
{
return color;
}
@Override
public String toString()
{
return("Hi my name is "+ this.getName() + ".\nMy breed,age and color are "
+ this.getBreed()+"," + this.getAge()+"," + this.getColor());
}
public static void main(String[] args)
{
Dog Krishanu = new Dog("Krishanu","Bull Dog", 20 , "black");
System.out.println(Krishanu.toString());
}
}