Created
August 30, 2020 23:38
-
-
Save julio-cesar-lacerda/5a1a50311a9cb890bb932f3c2cc7dfac 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
package com.company; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner ler = new Scanner(System.in); | |
int menu = 1,op; | |
double litro; | |
Carro carro1; | |
Carro carro2; | |
Carro carro3; | |
carro1 = new Carro(); | |
carro2 = new Carro(); | |
carro3 = new Carro(); | |
carro1.cor = "Vermelho"; | |
carro1.marca = "Chevrolet"; | |
carro1.modelo = "Impala"; | |
carro1.ano = 2000; | |
carro1.potencia = 450; | |
carro1.velocidadeAT = 0; | |
carro1.quantidade_CT = 10; | |
carro1.capacidade_MT = 100; | |
carro2.cor = "Azul"; | |
carro2.marca = "Volkswagem"; | |
carro2.modelo = "Gol"; | |
carro2.ano = 2010; | |
carro2.potencia = 250; | |
carro2.velocidadeAT = 0; | |
carro2.quantidade_CT = 30; | |
carro2.capacidade_MT = 100; | |
carro3.cor = "Cinza"; | |
carro3.marca = "Fiat"; | |
carro3.modelo = "Uno"; | |
carro3.ano = 1986; | |
carro3.potencia = 130; | |
carro3.velocidadeAT = 0; | |
carro3.quantidade_CT = 40; | |
carro3.capacidade_MT = 100; | |
int vai = 1; | |
while(vai == 1){ | |
int EC; | |
System.out.print("\n"); | |
System.out.println("Escolha um carro:"); | |
System.out.println("[1]"+carro1.modelo); | |
System.out.println("[2]"+carro2.modelo); | |
System.out.println("[3]"+carro3.modelo); | |
EC = ler.nextInt(); | |
if(EC <= 3 && EC >= 1){ | |
vai = 0; | |
} | |
} | |
while (menu == 1){ | |
System.out.print("\n"); | |
System.out.println("MEU CARRO"); | |
System.out.println("[1]Informação do veiculo"); | |
System.out.println("[2]Acelerar o veiculo"); | |
System.out.println("[3]Abastecer o veiculo"); | |
op = ler.nextInt(); | |
if(op == 1){ | |
System.out.println("MARCA DO VEICULO: "+carro1.marca); | |
System.out.println("MODELO DO VEICULO: "+carro1.modelo); | |
System.out.println("ANO DO VEICULO: "+carro1.ano); | |
System.out.println("COR DO VEICULO: "+carro1.cor); | |
System.out.println("POTENCIA DO VEICULO: "+carro1.potencia); | |
System.out.println("VELOCIDADE ATUAL DO VEICULO: "+carro1.velocidadeAT); | |
System.out.println("QUANTIDADE DE COMBUSTIVEL DO TANQUE: "+carro1.quantidade_CT); | |
System.out.println("CAPACIDADE MAXIMA DO TANQUE: "+carro1.capacidade_MT); | |
}else if(op == 2){ | |
carro1.Acelera(1,0.5); | |
}else if(op == 3){ | |
System.out.print("Quanto litro voce vai abastecer seu carro:"); | |
litro = ler.nextDouble(); | |
carro1.Abastecer(litro); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment