The Home Work has to be delievered before 9AM:
Note: You must save all your solution as
solution.kt
to be submitted before 9AM.⚠️
Interfce functions:
- isMoving()
Properties:
- startEngine: boolean value for the engine state
- type: string value for the type of the vehicle
- speed: int value for the speed of the vehicle
- gear: int value for the gear number of the vehicle
class functions:
- isMoving(): Check if speed more than zero then reterns true otherwise false.
- speedUp(): Increments speed value.
- changeGear(int): Changes gear's numbers.
- applyBrakes(): Sets the speed to zero.
- setType(String): Sets the type of the vehicle.
- printStates(): Print the state of the vehicle either is moving or not.
Class functions:
- changeGear(int): Checks the engine if it started it will change the gear number to a number between 0 and 5 otherwise sets to zero.
- speedUp(): Increments speed value by 20.
Class functions:
- changeGear(int): Checks the engine if it started it will change the gear number to a number between 0 and 10 otherwise sets to zero.
- speedUp(): Increments speed value by 5.
Output:
SportCar present state : (Moving)
speed: 80 gear: 5
Truck present state : (Moving)
speed: 40 gear: 2
Truck present state : (Stopped)
speed: 0 gear: 0