Redi School - Java Intermediate - OOP Class & Objects - Creating a Car class and using it in different ways.
Create a Java class for the real-life object “Car”:
- Name your class file “Car”.
- You want to store the
name
of the car (a String). - You want to store the
fuelLevel
of the car (a number between 0 and 100). - You also want to store the
maxSpeed
of the car (a number). - You also want to know if the car is
broken
(a boolean). - You want the car to be able to
drive()
and torefuel()
.
And then use the class “Car” by creating a new car object called “Mini”.
The solution is stored in this Github repository. You could try to solve the exercise before checking it out.
Please note that there is no single correct solution for this exercise; I've just chosen a simple one and there is for sure other valid / better solutions.