Giter Club home page Giter Club logo

onlineshoppingcart's Introduction

OnlineShoppingCart

Overview

OnlineShoppingCart This is an example of an Online Shopping Cart application implemented using the State Design Pattern. The application allows customers to add items to their shopping cart, remove items, confirm their order, and make payments. The state design pattern is employed to manage the transitions and behavior of the shopping cart as it progresses through various states during the shopping process.
The State Design Pattern is employed to ensure that the shopping cart behaves differently depending on its state. The key states and their responsibilities are defined in the ICartState interface.

Features

The shopping cart follows the State Design Pattern to transition between different states, namely empty, not empty and confirmed. Each state defines specific behavior and rules.

Add and Remove Items: Customers can add items to their cart, specifying the quantity. They can also remove items if needed.

Confirm Order: Once customers are satisfied with their selection, they can confirm their order. This locks the cart and prevents further changes.

Payment Processing: After confirmation, customers can make payments for the items in their cart. The application supports various payment methods.

Attributes and Functions

errorStatus : True if the last function had some execution error.
errorMessage : The Message related with the last executed error.
GetCartItems(): Retrieves the items in the cart.
GetStoreItems(): Retrieves the available items in the store.
GetStoreRates(): Retrieves the prices of items in the store.
AddItem(): Adds an item to the cart.
RemoveItem(): Removes an item from the cart.
Confirm(): Confirms the order, transitioning the cart to the confirmed state.
PerformPayment(): Processes the payment, transitioning the cart to the paid state.

States

EmptyCartState : Cart is empty. Only transition possible is to AddedCartState
AddedCartState : Cart has a few added items. Items can be removed, further items can be added, or order can be confirmed
ConfirmState : Order has been confirmed. If the right amount of payment is made, the cart will be emptied and the corresponding items from the store will be taken off

Context

Context is a class derived of the interface ICartState which handles the state transitions.

Design

State Diagram

State diagram

Dependency Diagram

Class diagram

Environment

The project builds and runs with Visual Studio Community 2022.

onlineshoppingcart's People

Contributors

unniisme avatar

Watchers

 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.