Task 3 - Movement of cars (objects) - solution:

The project consists of two files, ie. two classes. A class that describes a car should have defined attributes that pertain to the car and are relevant to this example. So velocity, distance displacement and time of an car. The constructor of that class is inserted into it, and method "toString() too".
Class Automobile is:Classes and objects: Class Automobile - definition
Figure 1: Class Automobile - definition
In the main class, we create the objects, and then the input data acceleration and time for both cars are entered:Objects in java example: Car movement-class definition
Figure 2: Car movement-class definition
In the main class, we create the objects, and then the input data acceleration and time for both cars are entered:After starting the application:objects example: Car movement-starting application
Figure 3: Car movement-starting application

Return to additional example - classes and objects in JAVA