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:
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:
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:
Let's start this application to see what will be printed at the output: