diff --git a/1ano/2semestre/poo/src/aula04/Car.java b/1ano/2semestre/poo/src/aula04/Car.java new file mode 100644 index 0000000..3b1076b --- /dev/null +++ b/1ano/2semestre/poo/src/aula04/Car.java @@ -0,0 +1,21 @@ +package aula04; + +class Car { + public String make; + public String model; + public int year; + public int kms; + + public Car(String make, String model, int year, int kms) { + this.make = make; + this.model = model; + this.year = year; + this.kms = kms; + } + + public void drive(int distance) { + //TODO: acumular distância percorrida + this.kms += distance; + } + +} diff --git a/1ano/2semestre/poo/src/aula04/SimpleCarDemo.java b/1ano/2semestre/poo/src/aula04/SimpleCarDemo.java new file mode 100644 index 0000000..a11d768 --- /dev/null +++ b/1ano/2semestre/poo/src/aula04/SimpleCarDemo.java @@ -0,0 +1,49 @@ +package aula04; + +import java.util.Scanner; + +public class SimpleCarDemo { + + static Scanner sc = new Scanner(System.in); + + static void listCars(Car[] cars) { + // TODO: lista todos os carros registados + // Exemplo de resultado + // Carros registados: + // Renault Megane Sport Tourer, 2015, kms: 35356 + // Toyota Camry, 2010, kms: 32456 + // Mercedes Vito, 2008, kms: 273891 + + System.out.println(); + System.out.println("Carros registados: "); + for (int i=0; i