diff --git a/classes/Cart.js b/classes/Cart.js index e69de29..96401cb 100644 --- a/classes/Cart.js +++ b/classes/Cart.js @@ -0,0 +1,16 @@ +const Product = require('./Product') + +class Cart { + constructor(prodcuts, total) { + this.products = []; + this.total = 0; + } + addProduct(newProduct) { + this.products.push(newProduct); + total += newProduct.price; + } + removeProduct(oldProduct){ + num = this.products.indexOf(oldProduct) + this.products.splice(num, 1) + } +} \ No newline at end of file diff --git a/classes/Product.js b/classes/Product.js index e69de29..8f6f87c 100644 --- a/classes/Product.js +++ b/classes/Product.js @@ -0,0 +1,13 @@ +class Product { + constructor(name, price, description, inStock) { + this.name = name; + this.price = price; + this.description = description; + this.inStock = true; + } + display(){ + return "Name: ${NAME}, Price: ${PRICE}, Description: ${DESCRIPTION}" + } +} + +module.exports = Product diff --git a/index.js b/index.js index efad601..b2c819e 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,5 @@ -// Import Classes Here - - - - +import { Product } from "./classes/Product" +const Product = require('./Product')