class Estudante implements Comparable<Estudante> {
private double nota;
public Estudante
(String nome,
double nota
) { this.nome = nome;
this.nota = nota;
}
return nome;
}
public void setNome
(String nome
) { this.nome = nome;
}
public double getNota() {
return nota;
}
public void setNota(double nota) {
this.nota = nota;
}
@Override
public int compareTo(Estudante o) {
o.nome = "QUEBRA DE ENCAPSULAMENTO";
return (int) (this.nota - o.getNota());
}
}
class TesteUniversidade {
public static void main
(String[] args
) { Estudante e1 = new Estudante("Joao", 5.5);
Estudante e2 = new Estudante("Ana", 6.5);
System.
out.
println(e2.
getNome()); System.
out.
println(e1.
compareTo(e2
)); System.
out.
println(e2.
getNome()); }
}
Y2xhc3MgRXN0dWRhbnRlIGltcGxlbWVudHMgQ29tcGFyYWJsZTxFc3R1ZGFudGU+IHsKCiAgICBwcml2YXRlIFN0cmluZyBub21lOwogICAgcHJpdmF0ZSBkb3VibGUgbm90YTsKCiAgICBwdWJsaWMgRXN0dWRhbnRlKFN0cmluZyBub21lLCBkb3VibGUgbm90YSkgewogICAgICAgIHRoaXMubm9tZSA9IG5vbWU7CiAgICAgICAgdGhpcy5ub3RhID0gbm90YTsKICAgIH0KCiAgICBwdWJsaWMgU3RyaW5nIGdldE5vbWUoKSB7CiAgICAgICAgcmV0dXJuIG5vbWU7CiAgICB9CgogICAgcHVibGljIHZvaWQgc2V0Tm9tZShTdHJpbmcgbm9tZSkgewogICAgICAgIHRoaXMubm9tZSA9IG5vbWU7CiAgICB9CgogICAgcHVibGljIGRvdWJsZSBnZXROb3RhKCkgewogICAgICAgIHJldHVybiBub3RhOwogICAgfQoKICAgIHB1YmxpYyB2b2lkIHNldE5vdGEoZG91YmxlIG5vdGEpIHsKICAgICAgICB0aGlzLm5vdGEgPSBub3RhOwogICAgfQoKICAgIEBPdmVycmlkZQogICAgcHVibGljIGludCBjb21wYXJlVG8oRXN0dWRhbnRlIG8pIHsKICAgICAgICBvLm5vbWUgPSAiUVVFQlJBIERFIEVOQ0FQU1VMQU1FTlRPIjsKICAgICAgIC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