Olá estou estudando Java e tenho duvidas. Para que serve está função super.
<blockquote>class No extends Ponto
{
private String nome;
public No (String nome, double x, double y)
{
super(x, y);
this.nome = nome;
}
public void defineNome(String nome)
{
this.nome = nome;
}
public String getNome()
{
return nome;
}
public String toString()
{
return nome + " (" + getX() + ", " + getY() + ")";
}
}
<blockquote>class Ponto
{
private double x;
private double y;
public Ponto(double x, double y)
{
this.x = x;
this.y = y;
}
public String getLocalizacao()
{
return "(" + x + ", " + y + ")";
}
public double getX()
{
return x;
}
public double getY()
{
return y;
}
public double getDistancia(Ponto p)
{
double dx2 = Math.pow( (p.getX() - this.x), 2);
double dy2 = Math.pow( (p.getY() - this.y), 2);
return Math.sqrt( dx2 + dy2 );
}
public void moverPara(double novoX, double novoY)
{
x = novoX;
y = novoY;
}
}
.