forked from learning-zone/java-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassesAndObjects.java
More file actions
44 lines (34 loc) · 858 Bytes
/
ClassesAndObjects.java
File metadata and controls
44 lines (34 loc) · 858 Bytes
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
package oopsconcepts;
public class ClassesAndObjects {
String name;
String breed;
int age;
String color;
// Constructor Declaration of class
public ClassesAndObjects(String name, String breed, int age, String color) {
this.name = name;
this.breed = breed;
this.age = age;
this.color = color;
}
public String getName() {
return name;
}
public String getBreed() {
return breed;
}
public int getAge() {
return age;
}
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) {
ClassesAndObjects tuffy = new ClassesAndObjects("tuffy", "Papillon", 5, "White");
System.out.println(tuffy.toString());
}
}