class TomadaDeDoisPinos implements TomadaDeDoisPinosIF{
@Override
public void conectar(ConectorDeDoisPinos conector) {
System.
out.
println(conector.
getDescricao()); }
}
class ConectorDeDoisPinos {
this.descricao = " conector de dois pinos.";
return this.descricao;
}
}
class CarregadorAntigo extends ConectorDeDoisPinos{
@Override
this.descricao = " conector de dois pinos.";
return "Carregador antigo conectando a tomada de " + descricao;
}
}
interface TomadaDeDoisPinosIF {
public void conectar(ConectorDeDoisPinos conector);
}
class Teste {
public static void main
(String[] args
) { ConectorDeDoisPinos cAntigo = new CarregadorAntigo();
TomadaDeDoisPinos tomadaDeDoisPinos = new TomadaDeDoisPinos();
tomadaDeDoisPinos.conectar(cAntigo);
}
}
Y2xhc3MgVG9tYWRhRGVEb2lzUGlub3MgaW1wbGVtZW50cyBUb21hZGFEZURvaXNQaW5vc0lGewoKCUBPdmVycmlkZSAKCXB1YmxpYyB2b2lkIGNvbmVjdGFyKENvbmVjdG9yRGVEb2lzUGlub3MgY29uZWN0b3IpIHsKCQlTeXN0ZW0ub3V0LnByaW50bG4oY29uZWN0b3IuZ2V0RGVzY3JpY2FvKCkpOyAgCgl9IAp9CiAKY2xhc3MgQ29uZWN0b3JEZURvaXNQaW5vcyB7CiAKCXByb3RlY3RlZCBTdHJpbmcgZGVzY3JpY2FvOyAgICAKCSAKCXB1YmxpYyBTdHJpbmcgZ2V0RGVzY3JpY2FvKCl7ICAKCQl0aGlzLmRlc2NyaWNhbyA9ICIgY29uZWN0b3IgZGUgZG9pcyBwaW5vcy4iOyAKCQlyZXR1cm4gdGhpcy5kZXNjcmljYW87ICAgCgl9IAoKfQoKY2xhc3MgQ2FycmVnYWRvckFudGlnbyBleHRlbmRzIENvbmVjdG9yRGVEb2lzUGlub3N7CgoJQE92ZXJyaWRlIAoJcHVibGljIFN0cmluZyBnZXREZXNjcmljYW8oKXsgIAoJCXRoaXMuZGVzY3JpY2FvID0gIiBjb25lY3RvciBkZSBkb2lzIHBpbm9zLiI7IAoJICAgIHJldHVyb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