Skip to content

Instantly share code, notes, and snippets.

@Ellpeck

Ellpeck/Car.java Secret

Created October 14, 2019 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ellpeck/7a0f31306d05473c10e8bca1685510a4 to your computer and use it in GitHub Desktop.
Save Ellpeck/7a0f31306d05473c10e8bca1685510a4 to your computer and use it in GitHub Desktop.
public class Car {
public String brandName;
public int horsepower;
public String licensePlate;
public int mileage;
public Car(String brandName, int horsepower, String licensePlate, int mileage) {
this.brandName = brandName;
this.horsepower = horsepower;
this.licensePlate = licensePlate;
this.mileage = mileage;
}
public void printInformation() {
System.out.println(this.brandName + ", " + this.horsepower + " HP, License Plate: " + this.licensePlate + ", " + this.mileage + " miles");
}
}
public class Main {
public static void main(String[] args) {
// I have no idea about cars so the mileage and HP are probably very unrealistic
Car honda = new Car("Honda", 120, "AC-HI 1234", 1000);
Car fiat = new Car("Fiat", 200, "AC-HI 2345", 2000);
Car vw = new Car("Volkswagen", 150, "AC-HI 3456", 0);
Car bmw = new Car("BMW", 200, "AC-HI 4567", 3000);
honda.printInformation();
fiat.printInformation();
vw.printInformation();
bmw.printInformation();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment