Created
September 6, 2013 03:45
-
-
Save fabioluciano/6459268 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Automovel implements Veiculo { | |
private byte numeroRodas; | |
private byte numeroPassageiros; | |
public byte getNumeroRodas() { | |
return this.numeroRodas; | |
} | |
public byte getNumeroPassageiros() { | |
return this.numeroPassageiros; | |
} | |
public Automovel(byte numeroRodas, byte numeroPassageiros) { | |
this.numeroRodas = numeroRodas; | |
this.numeroPassageiros = numeroPassageiros; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Caminhao implements Veiculo, VeiculoCarga { | |
public byte numeroRodas; | |
public byte numeroPassageiros; | |
public short cargaMaxima; | |
public byte getNumeroRodas() { | |
return this.numeroRodas; | |
} | |
public byte getNumeroPassageiros() { | |
return this.numeroPassageiros; | |
} | |
public short getCargaMaxima() { | |
return this.cargaMaxima; | |
} | |
public Caminhao(byte numeroRodas, byte numeroPassageiros, short cargaMaxima) { | |
this.numeroRodas = numeroRodas; | |
this.numeroPassageiros = numeroPassageiros; | |
this.cargaMaxima = cargaMaxima; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestaVeiculos { | |
public static void main(String[] args) { | |
Veiculo automovel = new Automovel((byte) 4, (byte) 5); | |
Caminhao caminhao = new Caminhao((byte) 16, (byte) 3, (short) 400); | |
Veiculo veiculo = new Caminhao((byte) 16, (byte) 3, (short) 400); | |
System.out.println("Automóvel - numero de rodas: " + automovel.getNumeroRodas()); | |
System.out.println("Automóvel - numero de passageiros: " + automovel.getNumeroPassageiros()); | |
System.out.println("-----"); | |
System.out.println("Caminhão - numero de rodas: " + caminhao.getNumeroRodas()); | |
System.out.println("Caminhão - numero de passageiros: " + caminhao.getNumeroPassageiros()); | |
System.out.println("-----"); | |
System.out.println("Veículo - numero de rodas: " + veiculo.getNumeroRodas()); | |
System.out.println("Veículo - numero de passageiros: " + veiculo.getNumeroPassageiros()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Veiculo { | |
byte getNumeroRodas(); | |
byte getNumeroPassageiros(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface VeiculoCarga { | |
short getCargaMaxima(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment