https://github.com/iamotz/shoppingcart
An OOP program to implement a shopping cart software
https://github.com/iamotz/shoppingcart
algorithm javascript oop shopping-cart
Last synced: 9 months ago
JSON representation
An OOP program to implement a shopping cart software
- Host: GitHub
- URL: https://github.com/iamotz/shoppingcart
- Owner: IAMOTZ
- Created: 2017-10-24T14:41:50.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-25T05:21:28.000Z (about 8 years ago)
- Last Synced: 2025-01-19T15:20:56.467Z (11 months ago)
- Topics: algorithm, javascript, oop, shopping-cart
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# shoppingCart
An OOP program to implement a shopping cart software
There are two major classes in this program, one is the ShoppingCart and the other is PromoShoppingCart.
Each of them are in different files inside the codes folder.
The ShoppingCart class does everything that a typical ShoppingCart software is needed to do.
* You can add item with `ShoppingCart.addItem(name, quantity, price, discount)`
* You can remove items with `ShoppingCart.removeItem(name, quantity, price, discount)`
* You can view the items added with `ShoppingCart.viewItems()`
* You can get the total price of items added with `ShoppingCart.total`
* You can get the number of items you added with `ShoppingCart.itemNumber`
* You can make payments with `ShoppingCart.checkout(payment)`
The PromoShoppingCart is subclass of the ShoppingCart class.(Inheritance)
It is very similar to the ShoppingCart class but it allows the users to buy 20 items without billing the user.
* Use thesame methods that ShoppingCart class uses and everything still works fine(polymorphism);
* Alter the value of `promoValue` property in the constructor to change the no of items the user can buy for free.
# Background Context
* The discount is to be in percentage
* The discount parameter is optional
* There is an Item helper class to handle if an Item has a discount or not.
# To use this project
* Clone the repo.
* cd into the projects directory
* Run the command `npm start` to see the program in action
* This would initialize a ShoppingCart class
* Add items ('Keyboard', 2, 400, 20)
* Add items ('mouse', 2, 300, 10)
* Add items ('Joystick', 4, 500)
* Then logs the items to the console with viewItems()
* If you don't use nodejs, then just run the code in any js runtime.