public class Cat {
String name = null;
int weight;
int age;
String color;
String address = null;
public void initialize(String name) {
this.name = name;
this.weight = 15;
this.age = 20;
this.color = "Blue";
}
public void initialize(String name, int weight, int age) {
this.name = name;
this.weight = weight;
this.age = age;
this.color = "Pink";
}
public void initialize(String name, int age) {
this.name = name;
this.weight = 15;
this.age = age;
this.color = "Pink";
}
public void initialize(int weight, String color) {
this.name = "Mark";
this.weight = weight;
this.age = 15;
this.color = color;
}
public void initialize(int weight, String color, String address) {
this.name = "Mark";
this.weight = weight;
this.age = 15;
this.color = color;
this.address = address;
}
public static void main(String[] args) {
}
}
Initializing cats - i can not meet the last two Requirements
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Abdul-Hamed Mohammed
18 February 2020, 09:34
The last two Requirements are failing due to initializing the name variable in both of them. Delete the name variable from the methods and should solve your problem.
0
krystian
20 December 2019, 15:10
I have added my solution :) can not you see that ?
0
Guadalupe Gagnon
20 December 2019, 14:22
You need to share your solution
0