complete lesson
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user