com/codegym/task/task05/task0517/Cat.java:14: error: cannot reference weight before supertype constructor has been called
this(weight, color);
^
com/codegym/task/task05/task0517/Cat.java:14: error: cannot reference color before supertype constructor has been called
this(weight, color);
^
package com.codegym.task.task05.task0517;
/*
Creating cats
Q:
Create the Cat class with five constructors:
- Name,
- Name, weight, age
- Name, age (standard weight)
- Weight, color (name, address, and age are unknown; the cat is homeless)
- Weight, color, address (someone else's unfamiliar pet)
The constructor's job is to make the object valid.
For example, if the weight is unknown, then you need to specify some average weight.
A cat can't weigh nothing.
The same applies to age. But there may or may not be a name (i.e. name might be null).
The same applies to the address (it might be null).
*/
public class Cat {
//write your code here
private String name, color, address;
private int weight, age;
public Cat(String name) {
this.name = name;
}
public Cat(String name, int weight, int age) {
this(name);
this.weight = weight;
this.age = age;
}
public Cat(String name, int age) {
this(name);
this.age = age;
this.weight = 50;
}
public Cat(int weight, String color) {
this.weight = weight;
this.color = color;
this.weight = 50;
}
public Cat(int weight, String color, String address) {
this(weight, color);
this.address = address;
}
public static void main(String[] args) {
}
}