Coder Social home page Coder Social logo

unidays-tech-challenge's Introduction

UNiDAYS Discounts Coding Challenge

Introduction

This challenge is for you to make use of your problem solving skills as well as demonstrate your understanding of good object-oriented programming and SOLID design principles.

At UNiDAYS our business is built on providing discounts to students. Your challenge is to build a basic discount system that applies discounts to an online shopping order and calculates the total price based on a set of pricing rules.

You may complete the challenge in any programming language you wish.

Pricing Rules

Item Price Discount
A £8.00 None
B £12.00 2 for £20.00
C £4.00 3 for £10.00
D £7.00 Buy 1 get 1 free
E £5.00 3 for the price of 2

Delivery Charges

Delivery charge £7.00

Free delivery on orders over £50.00 (inclusive)

Interface

Implement a UnidaysDiscountChallenge class with two public methods.

  1. AddToBasket - Pass in an item
  2. CalculateTotalPrice - Calculate and return the total price, result should include the following
    • Total - Total price of all items after applying any discounts
    • DeliveryCharge - The delivery charge for the order

It should be possible to initialise your UnidaysDiscountChallenge class with the pricing rules. The example below shows how the interface might be used.

example = new UnidaysDiscountChallenge(pricingRules);

example.AddToBasket(itemOne);
example.AddToBasket(itemTwo);

result = example.CalculateTotalPrice();

totalPrice = result.Total;
deliveryCharge = result.DeliveryCharge;
overallTotal = totalPrice + deliveryCharge;

Example Test Cases

Items Total Delivery Charge
None £0.00 £0.00
A £8.00 £7.00
B £12.00 £7.00
C £4.00 £7.00
D £7.00 £7.00
E £5.00 £7.00
BB £20.00 £7.00
BBB £32.00 £7.00
BBBB £40.00 £7.00
CCC £10.00 £7.00
CCCC £14.00 £7.00
DD £7.00 £7.00
DDD £14.00 £7.00
EE £10.00 £7.00
EEE £10.00 £7.00
EEEE £15.00 £7.00
DDDDDDDDDDDDDD £49.00 £7.00
BBBBCCC £50.00 £0.00
ABBCCCDDEE £55.00 £0.00
EDCBAEDCBC £55.00 £0.00

Deliverables

You should provide a copy of your code in a publicly accessible location (e.g. Github, Bitbucket etc).

Your solution should include documentation describing how to build and run your code as well your approach to the problem.

We're not too fussy about what platform your program runs on, but we do require that we're able to build and run your code ourselves.

unidays-tech-challenge's People

Contributors

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