Giter Club home page Giter Club logo

shipping's Introduction

Home test

Our story:

  • There is a shipping service. It helps Vietnamese buy products on Amazon website. After a client provides items urls on Amazon, we will have: Amazon price, product weight, width, height, depth
  • We need to calculate a gross price for an order (contains many items) follow formulas:
  • gross price = item price 1 + item price 2 + ...
  • item price = amazon price + shipping fee
  • shipping fee = max (fee by weight, fee by dimensions)
  • fee by weight = product weight x weight coefficient
  • fee by dimension = width x height x depth x dimension coefficient

Example coefficients:

  • weight coefficient: $11/kg
  • dimension coefficient: $11/m3

What do you need to do?

  1. Create the necessary and flexible structure of classes to calculate the gross price for an order.
  2. Write unit tests for classes

Requirements:

  1. No need to implement UI

  2. Don't use any framework. We are implementing business logic which should be separated from framework (clean architecture)

  3. Code must be executable without any exceptions

  4. Code must satisfy PSR-12

  5. Classes must satisfy S.O.L.I.D principles and should be auto loaded with autoloading standard PSR-4

  6. Coefficients are configurable

  7. Use PHP7 if possible

  8. Shipping fee must be flexible. For example, shipping fee for a smartphone (300g) must be less than a diamond ring (10g) so we need be add fee by product type someday

  • shipping fee = max (fee by weight, fee by dimensions, fee by product type)
  • How do we add fee by product type without changing shipping fee code?
  • No need to implement fee by product type

Install

Use PHP 7.4 and PHPUnit tess

  • composer install

From root to run example:

  • php src/index.php

Tests

From root

  • ./vendor/bin/phpunit tests

shipping's People

Watchers

son le 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.