Its so bad I cant attach it
Error code: constructor Cat(java.lang.String,int) is already defined in class com.codegym.task.task05.task0517.Cat:
Cat.java, line: 27, column: 12
Code:
package com.codegym.task.task05.task0517;
/*
Creating cats
*/
public class Cat {
//write your code here
private String name;
private int age=3;
private int weight=27;
private String color;
private String address;
public Cat(String name){
this.name=name;
}
public Cat(String name, int weight, int age){
this.name=name;
this.age=age;
this.weight=weight;
}
public Cat(String name, int age){
this.name=name;
this.age=age;
}
public Cat(String color, int weight){
this.color=color;
this.weight=weight;
}
public Cat(String color, int weight, String address){
this.color=color;
this.weight=weight;
this.address=address;
}
public static void main(String[] args) {
}
}
Confused
Resolved
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
Ondrej
4 April 2019, 17:12solution
Change order of color and weight regarding the conditions in this constructor.
public Cat(String color, int weight){ this.color=color; this.weight=weight; }
0
Guadalupe Gagnon
31 March 2019, 03:19solution
You have 2 constructors that take String and int as arguments. This is illegal and causing your problem.
+4
Mark Fernandez
30 March 2019, 19:56
You need assign color to the cat, then your code will work
0
Jeff Jeffy
31 March 2019, 02:04
I did that?
0