-
You have abstract class
Machine
and three sub-classes:Bulldozer
,Excavator
andTruck
. Feel free to add some type-specific fields to these classes. -
Each machine has the ability to start working.
-
There is MachineProducer interface created. The goal of implementation of this interface is to create a list of specific machines (
Bulldozer
,Excavator
andTruck
). You should have at least 3 implementations:BulldozerProducer
,ExcavatorProducer
,TruckProducer
; Please parameterize yourMachineProducer
and replaceObject
inget()
with the suitable option.public interface MachineProducer<PARAMETRIZE ME>{ ... }
-
In
MachineProducer
implementations your methodget()
should return the list of specific machines. For example:List<Bulldozer> get();
or
List<Truck> get();
or
List<Excavator> get();
-
There is also
MachineService
interface created. You need to parameterize it as well and replaceObject
in method signature with the right option (use PECS):- the method
getAll(Class type)
produces the list of machines based on the input param. - the method
fill(List<Object> machines, Object value)
fills the machines list with passed value. - the method
startWorking()
should be able to accept a list containing any Machine.
- the method
When you parameterize interface MachineService
keep in mind that we want to restrict types that can be used with it.
Not allow:
MachineServiceImpl implements MachineService<Dog>
Allow:
MachineServiceImpl implements MachineService<Truck>
``
- Use the created class
MachineServiceImpl
implementing MachineService and realize these methods:
getAll(Class type)
- based on the input class type, choose the right MachineProducer implementation and call itsget()
method.
For example: if (type == Bulldozer.class)
- we should call the get()
method from right implementation of MachineProducer (the one that will return List<Bulldozer>
) and return these machines.
-
fill(List<Object> machines, Object value)
- update to the passed value (which can be of any Machine subtype) all elements in themachines
list. -
startWorking()
- calldoWork
on every Machine in the list.