Git Product home page Git Product logo

shoppingbasketdotnet's Introduction

ShoppingBasketDotNet

A c# implementation of a shopping basket that allows different discounts

You can add different Items to your ShoppingBasket, and when you CalculateTotal, it will show you the amount to pay, taking into account all the different Discounts that were definted.

##Install & Run tests

  1. clone this repo
  2. build in Visual Studio (this should also restore packages)
  3. run tests in Visual Studio ctrl + R + A
    (this project doesn't have a GUI / CLI; it's just a demo of the business logic implementation)

##About the solution This solution, like its parallel Ruby implementation, uses the visitor pattern to separate the implementation of the ShoppingBasket and the different Discounts.
The ShoppingBasket will apply all the predefined discounts on itself, allowing different discounts with different logic to be implemented separately.

In this case, we defined two different Discounts that have different logic (one that's of the type "buy X get Y free", and one of the type "buy X of product A, and get a Y% discount on product B").

##What can be improved Obviously this is just a little demo thing; It can be improved in the following ways:

  • Adding some sort of interface
  • Using Value Objects to make sure parameters are within permitted range (i.e quantity should only be positive)
  • Creating an ItemInBasket class instead of using the much less obvious KeyValuePair<Item,int> all over the place.

shoppingbasketdotnet's People

Contributors

sjhonny-e avatar

Watchers

James Cloos 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.