Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 72e0564

Browse files
authored
Merge pull request #2 from Aakreete/main
Vehicle class and method created
2 parents 77898b4 + 1504520 commit 72e0564

File tree

7 files changed

+249
-183
lines changed

7 files changed

+249
-183
lines changed

src/Animal.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
public class Animal {
2+
String name;
3+
float weight;
4+
String size;
5+
6+
//a constructor is an especial method that execute at the beginning when object of class is created.
7+
8+
//no parameterized
9+
Animal() {
10+
11+
}
12+
13+
//parameterized
14+
Animal(String name, float weight, String size) {
15+
this.name = name;
16+
this.weight = weight;
17+
this.size = size;
18+
}
19+
20+
Animal(String name, float weight) {
21+
this.name = name;
22+
this.weight = weight;
23+
24+
}
25+
26+
Animal(String name) {
27+
this.name = name;
28+
29+
}
30+
31+
Animal(String size, String name) {
32+
this.size = size;
33+
this.name = name;
34+
35+
}
36+
37+
//copy constructor
38+
Animal(Animal animal) {
39+
this.name = animal.name;
40+
this.weight = animal.weight;
41+
this.size = animal.size;
42+
}
43+
44+
}
45+

src/BinaryTreeYT.java

Lines changed: 0 additions & 180 deletions
This file was deleted.

src/Bird.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
public class Bird {
2+
String colour;
3+
String family;
4+
float length;
5+
6+
// Constructor with 'family' parameter
7+
Bird(String family){
8+
this.family=family;
9+
}
10+
11+
//important: why can't I make constructor that assign colour properties of the bird?
12+
13+
// Constructor with 'colour' and 'family' parameters
14+
Bird(String colour, String family, float length){
15+
this.colour=colour;
16+
this.family=family;
17+
this.length=length;
18+
}
19+
20+
// Constructor with 'colour' and 'length' parameters
21+
Bird(String colour, float length){
22+
this.colour=colour;
23+
this.length=length;
24+
}
25+
26+
// Constructor with 'length' and 'family' parameters
27+
Bird(float length, String family){
28+
this.length=length;
29+
this.family=family;
30+
}
31+
32+
// Constructor with 'length' parameter
33+
Bird(float length){
34+
this.length=length;
35+
}
36+
}

src/Furniture.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class Furniture {
2+
String name;
3+
int breadth;
4+
5+
Furniture(String name, int breadth){
6+
this.name=name;
7+
this.breadth=breadth;
8+
}
9+
10+
}
11+
//why we make constructor: to make the object.
12+
//syntax of object Wall s1= new House();
13+
//public class House{}
14+
// this is constructor House(){}

src/House.java

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
public class House {
2+
//this is data declaration while creating class
3+
String name;
4+
int bedrooms;
5+
int toilets;
6+
7+
8+
//parametrized constructor
9+
House(String name, int bedrooms, int toilets) {
10+
this.name = name;
11+
this.bedrooms = bedrooms;
12+
this.toilets = toilets;
13+
14+
}
15+
void findingArea(){
16+
System.out.println("This is the finding area functions.");
17+
}
18+
19+
void cookingFood(){
20+
System.out.println("This is the cooking food functions");
21+
}
22+
void cleaningBathroom(){
23+
System.out.println("This is the cleaning bathroom functions");
24+
}
25+
void changingBedsheet(){
26+
System.out.println("This is the changing bedsheet functions.");
27+
}
28+
void HooveringHouse(){
29+
System.out.println("This is the hoovering house functions");
30+
}
31+
32+
33+
//no parameter constructor
34+
House() {
35+
36+
}
37+
38+
House(String name) {
39+
this.name = name;
40+
}
41+
42+
House(String name, int bedrooms) {
43+
this.name = name;
44+
this.bedrooms = bedrooms;
45+
}
46+
47+
House(int bedrooms, String name) {
48+
this.bedrooms = bedrooms;
49+
this.name = name;
50+
}
51+
52+
House(int toilets, int bedrooms, String name) {
53+
this.toilets = toilets;
54+
this.bedrooms = bedrooms;
55+
this.name = name;
56+
57+
}
58+
59+
House(int bedrooms, int toilets) {
60+
this.bedrooms = bedrooms;
61+
this.toilets = toilets;
62+
}
63+
//copy constructor
64+
//h1 is the data type of House that's why it expect the data type house as we have created h1 in main folder
65+
House(House h1){
66+
this.name=h1.name;
67+
this.toilets=h1.toilets;
68+
this.bedrooms=h1.bedrooms;
69+
}
70+
71+
}
72+

0 commit comments

Comments
 (0)