complete lesson

This commit is contained in:
2020-03-28 19:49:57 +01:00
parent 86ffdd7397
commit cbfbdab6c4
7 changed files with 117 additions and 7 deletions

View File

@ -10,7 +10,9 @@ public class Car {
public String model = "";
public String manufacturer = "";
public String get_info() {
return "Car Information:\n- manufacturer: " + this.manufacturer + "\n- model: " + this.model;
public void print_info() {
System.out.println("Car Information:");
System.out.println("- manufacturer: " + this.manufacturer);
System.out.println("- model: " + this.model);
}
}

View File

@ -6,13 +6,13 @@ public class main {
a.manufacturer = "Benz";
a.model = "Velo";
// Do the same for a second car
// do the same for a second car
Car b = new Car();
b.manufacturer = "Ford";
b.model = "Model T";
// use a function of the car class to print out the information
System.out.println(a.get_info());
System.out.println(b.get_info());
a.print_info();
b.print_info();
}
}