-
-
Save Ellpeck/7a0f31306d05473c10e8bca1685510a4 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
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"); | |
} | |
} |
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 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