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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/Animal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
public class Animal {
String name;
float weight;
String size;

//a constructor is an especial method that execute at the beginning when object of class is created.

//no parameterized
Animal() {

}

//parameterized
Animal(String name, float weight, String size) {
this.name = name;
this.weight = weight;
this.size = size;
}

Animal(String name, float weight) {
this.name = name;
this.weight = weight;

}

Animal(String name) {
this.name = name;

}

Animal(String size, String name) {
this.size = size;
this.name = name;

}

//copy constructor
Animal(Animal animal) {
this.name = animal.name;
this.weight = animal.weight;
this.size = animal.size;
}

}

180 changes: 0 additions & 180 deletions src/BinaryTreeYT.java

This file was deleted.

36 changes: 36 additions & 0 deletions src/Bird.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public class Bird {
String colour;
String family;
float length;

// Constructor with 'family' parameter
Bird(String family){
this.family=family;
}

//important: why can't I make constructor that assign colour properties of the bird?

// Constructor with 'colour' and 'family' parameters
Bird(String colour, String family, float length){
this.colour=colour;
this.family=family;
this.length=length;
}

// Constructor with 'colour' and 'length' parameters
Bird(String colour, float length){
this.colour=colour;
this.length=length;
}

// Constructor with 'length' and 'family' parameters
Bird(float length, String family){
this.length=length;
this.family=family;
}

// Constructor with 'length' parameter
Bird(float length){
this.length=length;
}
}
14 changes: 14 additions & 0 deletions src/Furniture.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Furniture {
String name;
int breadth;

Furniture(String name, int breadth){
this.name=name;
this.breadth=breadth;
}

}
//why we make constructor: to make the object.
//syntax of object Wall s1= new House();
//public class House{}
// this is constructor House(){}
72 changes: 72 additions & 0 deletions src/House.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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;

}
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;
}

}

Loading