-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainClass.java
More file actions
113 lines (103 loc) · 1.98 KB
/
Copy pathMainClass.java
File metadata and controls
113 lines (103 loc) · 1.98 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//package oops;
//class Cat{
// boolean fur;
// String color, breed;
// int legs, eyes;
//
// public void walk() {
// System.out.println("Cat is walking");
// }
// public void eat() {
// System.out.println("Cat is eating");
// }
// public void sleep() {
// System.out.println("Cat is sleeping");
// }
// public void desc() {
// System.out.println("My cat has "+legs+" legs and "+eyes+" eyes. The breed is "+breed+ " and Color is "+ color);
// }
//
//}
//class Dog{
// String name, breed;
//
// public void jump() {
// System.out.println("My dog "+ name+ " jumped.");
// }
//
// public void desc() {
// System.out.println("My dog name is "+name+" and breed is "+breed);
// }
//}
//public class MainClass {
// public static void main(String[] args) {
//
// Cat c1 = new Cat();
// Cat c2 = new Cat();
//
// c1.legs = 3;
// c2.legs = 4;
// c1.color = "black";
// c2.color = "brown";
// c1.eyes = 2;
// c2.eyes = 1;
// c1.walk();
// c2.eat();
// c1.breed = "bimran";
// c2.breed = "ragdoll";
//
// c1.desc();
// c2.desc();
//
// Dog d1 = new Dog();
// Dog d2 = new Dog();
//
// d1.name = "Champu";
// d2.name = "Raju";
// d1.breed = "Husky";
// d2.breed = "Dingo";
//
// d1.jump();
// d2.jump();
// d1.desc();
// d2.desc();
// }
//
//}
package oops;
class Cat{
boolean hasfur;
String color, breed;
int leg, eye;
public void walk() {
System.out.println("Cat is walking");
}
public void eat() {
System.out.println("Cat is eating");
}
public void desc() {
System.out.println("My cat has "+leg+" legs and "+eye+" eyes.");
}
}
class Dog{
String name;
public void jump() {
System.out.println("My dog "+name+" is jumping");
}
}
public class MainClass{
public static void main(String args[]) {
Cat cat1 = new Cat();
Cat cat2 = new Cat();
cat1.leg = 4;
cat1.eye = 2;
cat1.desc();
cat1.walk();
cat2.eat();
Dog D1 = new Dog();
Dog D2 = new Dog();
D1.name = "Lawdu";
D2.name = "Lalit";
D1.jump();
}
}