Below is a version of CarTest
that uses
toString()
and System.out.println()
instead of
printing the fields directly and thus works with the new
Car
class that makes its fields private.
class CarTest5 {
public static void main(String args[]) {
Car c = new Car("New York A45 636", 123.45);
System.out.println(c);
for (int i = 0; i < 15; i++) {
c.accelerate(10.0);
System.out.println(c);
}
}
}