Git Product home page Git Product logo

jv-strategy's Introduction

jv-strategy


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

In this task, we'll need help with the Strategy pattern. First of all, you need to create a DiscountService interface with the method getDiscount() with the return type double. It must be located in the 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

In each of these implementations in result of the execution of the method getDiscount() must return a discount according to the table above. Also, these implementations must be located in the core.basesyntax.strategy.impl package.

The last step will be the creation of a class called DiscountStrategy located in the 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 the DiscountService implementation.

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

jv-strategy's People

Contributors

boroda4436 avatar kseniiamakarova avatar nacenik avatar nick97-git avatar resci avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.