2
It is certain to "set" the variables passing by parameter directly in the constructor, equal to this code?
public class Retangulo extends FiguraGeometrica{
private double largura;
private double altura;
public Retangulo(double altura, double largura){
this.altura = altura;
this.largura = largura;
}
public double obterArea(){
return largura * altura;
}
public double obterPerimetro(){
return 2 * largura + 2 * altura;
}
}
Or so?:
public Retangulo(Retangulo x){
this.altura = x.altura;
this.largura = x.largura;
}
Or should I do a procedure for each variable?
Good question. But try to give a new one in the second option and think about how other constructors are used and pq
– cpll
Related: https://answall.com/q/73530/112052
– hkotsubo