Git Product home page Git Product logo

jv-strategy's Introduction

jv-strategy


Imagine you have сhain of stores. You need to implement discount system for people in some special events of a year like New Year.

In this task we'll need help of Strategy pattern. First of all, you need to create DiscountService interface with method getDiscount() with return type double. It must be located in core.basesyntax.strategy package.

You must create its implementations (with the same names) with such discounts:

Implementation name Discount
DefaultDiscountService 0
NewYearDiscountService 20
BirthdayDiscountService 33
BlackFridayDiscountService 45

Each of this implementation in result of execution of method getDiscount() must return discount according to table above. Also, these implementations must be located in core.basesyntax.strategy.impl package.

The last step will be creation of class called DiscountStrategy and located in core.basesyntax package. It must have method getDiscountServiceBySpecialEvent(String specialEvent) with return type DiscountService where specialEvent can have such values: "Birthday", "Black Friday", "New Year".

Using specialEvent, you must write code that defines DiscountService implementation.

In case if passed specialEvent doesn't have specific implementation you must return DefaultDiscountService by default.

jv-strategy's People

Contributors

nick97-git 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.