Created
June 1, 2020 13:48
-
-
Save jcbombardelli/d40744b32db6259afccc0282bd4e6224 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Carro { | |
| private String cor; | |
| private int anoFabricacao; | |
| private int qtdPortas; | |
| private String combustivel; | |
| private String marca; | |
| private String placa; | |
| private int assentos; | |
| // Metodo de acesso SET | |
| public void setCor(String novaCor) { | |
| cor = novaCor; | |
| } | |
| // Metodo de acesso GET | |
| public String getCor() { | |
| return cor; | |
| } | |
| public void acelerar() { | |
| System.out.println("Carro acelerando !!!"); | |
| } | |
| public void virarCarro(String direcao) { | |
| System.out.println("Virando para a " + direcao); | |
| } | |
| public void acenderFarois() { | |
| System.out.println("Acendendo faróis"); | |
| } | |
| } |
This file contains hidden or 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 Programa { | |
| public static void main(String[] args) { | |
| System.out.println("----------------------------------"); | |
| Carro novoCarro = new Carro(); | |
| novoCarro.acenderFarois(); | |
| // novoCarro.anoFabricacao = 2010; | |
| // novoCarro.assentos = 5; | |
| // novoCarro.combustivel = "Etanol"; | |
| novoCarro.setCor("Preto"); | |
| novoCarro.setCor("Branco"); | |
| novoCarro.setCor("Vermelho"); | |
| System.out.print("A cor do carro é : "); | |
| System.out.println(novoCarro.getCor()); | |
| System.out.println("----------------------------------"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment