2
I have an abstract class called Veiculo
which has two builders:
public abstract class Veiculo {
// Atributos ...
public Veiculo(Marcas marca, int velocidade){...}
public Veiculo(Marcas marca, int velocidade, Cores cor){...}
// Métodos abstratos ...
}
Besides this class, I have another call Carro
, extending the abstract class Veiculo
and implements all methods declared as abstract.
But the class Carro
do not overwrite the constructors because, I wish to use the constructors of the inherited class in the class Carro
and in other classes that I create and extend Veiculo
.
Carro veiculo = new Carro(Marcas.FERRARI, 420, Cores.VERMELHO);
Below is the class code:
public class Carro extends Veiculo {
public String abrirJanela(){...}
public String dirigir(){...}
public String getMarca(){...}
public String quebrar(){...}
}
The problem that is happening is that the Intellij IDEA shows me the following error message on the line on which I extend the class:
There is no default constructor available in 'vehicle.Vehicle'
What I’m doing wrong in my code?
To supplement his reply, this behaviour is described in the second to last paragraph of documentation. It’s a normal behavior :)
– nullptr