GithubHelp home page GithubHelp logo

pointofsale's Introduction

README (THIS IS JUST AN EXCERCISE) DO NOT USE THIS

This README would normally document whatever steps are necessary to get your application up and running.

I used BDD for this and here is the feature file corresponding to the tests PointOfSaleCheckout.feature

Prerequisites

  • Java 8 SDK
  • Maven 3.0

Run Tests

Run the following command in the project root folder where is located pom.xml

mvn test

Use the API

In order to use the API you need an instance of PointOfSaleFacade

PointOfSaleFacade pointOfSaleFacade = new PointOfSaleFacade();

Add a new product

pointOfSaleFacade.getProductService().add(new Product("A",new BigDecimal(2.00)));
...

Set volume price

pointOfSaleFacade.getProductService().addVolumePrice(new ProductVolumePrice("A",4,new BigDecimal(7.00)));
...

Scan a product

pointOfSaleFacade.getPointOfSaleTerminaService().scan("A");
....

Calculate Total

BigDecimal total = pointOfSaleFacade.getPointOfSaleTerminaService().calculateTotal();

Checkout (Set everything ready for another order)

pointOfSaleFacade.getPointOfSaleTerminaService().checkout();

Full sample

public class Main {
    public static void main(String[] args) throws EntryNotFoundException {

        PointOfSaleFacade pointOfSaleFacade = new PointOfSaleFacade();

        pointOfSaleFacade.getProductService().add(new Product("A",new BigDecimal(2.00)));
        pointOfSaleFacade.getProductService().addVolumePrice(new ProductVolumePrice("A",4,new BigDecimal(7.00)));


        pointOfSaleFacade.getProductService().add(new Product("B",new BigDecimal(12.00)));

        pointOfSaleFacade.getProductService().add(new Product("C",new BigDecimal(1.25)));
        pointOfSaleFacade.getProductService().addVolumePrice(new ProductVolumePrice("C",6,new BigDecimal(6.00)));

        pointOfSaleFacade.getProductService().add(new Product("D",new BigDecimal(0.15)));

        pointOfSaleFacade.getPointOfSaleTerminaService().scan("A");
        pointOfSaleFacade.getPointOfSaleTerminaService().scan("B");
        pointOfSaleFacade.getPointOfSaleTerminaService().scan("C");
        pointOfSaleFacade.getPointOfSaleTerminaService().scan("D");

        System.out.println(pointOfSaleFacade.getPointOfSaleTerminaService().calculateTotal());

        pointOfSaleFacade.getPointOfSaleTerminaService().checkout();
    }
}

pointofsale's People

Contributors

frankely avatar

Stargazers

 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.