Example 4-Sale of cars solution

The project should contain two classes, the main one containing the main method and which should control the entire flow of the program and the second class Automobile, which describes the car and which should specify the characteristics of the car (data that is important for a car when buying). The structure of classes (files) in this project, which is called AutomobilesSales, can be seen in the following image:Objects in java examples-Automobiles Sales Application-tab Projects
Fifure 1: Automobiles Sales Application-tab Projects
First you need to create the project and the main class, only empty, which in this case is called the same as the project. Then add a new Automobile.java file containing the class of the same name, as shown in the following image:objects in java example: Class Automobile-definition
Figure 2: Class Automobile-definition
Then you should return to the main class and complete the task. The Automobile class will be used to create objects that represent cars for sale:Class AutomobilesSales-definition
Figure 3: Class AutomobilesSales-definition
Let's start this application to see what will be printed at the output:objects in java example: Project AutomobilesSales-execution
Figure 4: Project AutomobilesSales-execution

Return to additional example - classes and objects in JAVA