Repository navigation
Expand file tree
/
Copy pathHouse.java
More file actions
74 lines (58 loc) · 1.64 KB
/
Copy pathHouse.java
File metadata and controls
74 lines (58 loc) · 1.64 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
public class House {
//this is data declaration while creating class
String name;
int bedrooms;
int toilets;
//parametrized constructor
House(String name, int bedrooms, int toilets) {
this.name = name;
this.bedrooms = bedrooms;
this.toilets = toilets;
}
//methods
void findingArea(){
System.out.println("This is the finding area functions.");
}
void cookingFood(){
System.out.println("This is the cooking food functions");
}
void cleaningBathroom(){
System.out.println("This is the cleaning bathroom functions");
}
void changingBedsheet(){
System.out.println("This is the changing bedsheet functions.");
}
void HooveringHouse(){
System.out.println("This is the hoovering house functions");
}
//no parameter constructor
House() {
}
House(String name) {
this.name = name;
}
House(String name, int bedrooms) {
this.name = name;
this.bedrooms = bedrooms;
}
House(int bedrooms, String name) {
this.bedrooms = bedrooms;
this.name = name;
}
House(int toilets, int bedrooms, String name) {
this.toilets = toilets;
this.bedrooms = bedrooms;
this.name = name;
}
House(int bedrooms, int toilets) {
this.bedrooms = bedrooms;
this.toilets = toilets;
}
//copy constructor
//h1 is the data type of House that's why it expect the data type house as we have created h1 in main folder
House(House h1){
this.name=h1.name;
this.toilets=h1.toilets;
this.bedrooms=h1.bedrooms;
}
}