Code Monkey home page Code Monkey logo

jv-pecs's Introduction

jv-pecs

  1. You have abstract class Machine and three sub-classes: Bulldozer, Excavator and Truck. Feel free to add some type-specific fields to these classes.

  2. Each machine has the ability to start working.

  3. There is MachineProducer interface created. The goal of implementation of this interface is to create a list of specific machines (Bulldozer, Excavator and Truck). You should have at least 3 implementations: BulldozerProducer, ExcavatorProducer, TruckProducer; Please parameterize your MachineProducer and replace Object in get() with the suitable option.

    public interface MachineProducer<PARAMETRIZE ME>{ ... }
  4. In MachineProducer implementations your method get() should return the list of specific machines. For example:

    List<Bulldozer> get();

    or

    List<Truck> get();

    or

    List<Excavator> get();
  5. There is also MachineService interface created. You need to parameterize it as well and replace Object 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.

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>
``

  1. 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 its get() 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 the machines list.

  • startWorking() - call doWork on every Machine in the list.

jv-pecs's People

Contributors

kseniiamakarova avatar boroda4436 avatar romandubovskyi avatar resci avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.