You need to write a Car class with the Speed and Fuel interfaces. In the Car class, use class delegation to implement the speed and fuel level change functionality.
Here is the plan to follow:
- Create the
Speedinterface with theincreaseSpeed()anddeclineSpeed()functions. - Create the
Fuelinterface with the functionsconsumerFuel()andaddFuel(). - Implement
SpeedHandlerwith step 10 andFuelHandlerwith step 5 forconsumerFuel()and step 10 foraddFuel()delegate classes forSpeedandFuelinterfaces, respectively.
Now you need to create the speedDelegate and fuelDelegate delegates in the Car class.