diff --git a/classes/Cart.js b/classes/Cart.js index e69de29..9554c7a 100644 --- a/classes/Cart.js +++ b/classes/Cart.js @@ -0,0 +1,16 @@ +class Cart { + products = []; + total = 0; + + addProduct(Product) { + this.products.push(Product); + this.total+= Product.price; + } + + removeProduct(i) { + this.total -= this.products[i].price; + this.products.splice(i,1); + } +} + +module.exports = Cart; \ No newline at end of file diff --git a/classes/Customer.js b/classes/Customer.js index e69de29..e35e6ea 100644 --- a/classes/Customer.js +++ b/classes/Customer.js @@ -0,0 +1,18 @@ +class Customer{ + constructor(name,email,shippingAddress){ + this.name=name; + this.email=email; + this.shippingAddress=shippingAddress; + this.orderHistory=[] + + } + + addToOrderHistory(cart){ + + this.orderHistory.push(cart) + } + +} + + +module.exports=Customer; \ No newline at end of file diff --git a/classes/Product.js b/classes/Product.js index e69de29..299bc7f 100644 --- a/classes/Product.js +++ b/classes/Product.js @@ -0,0 +1,15 @@ +class Product{ + constructor(name,price,description){ + this.name=name; + this.price=price; + this.description=description; + this.inStock= true; + + } + display(){ + return `Name: ${this.name}, Price: $${this.price}, Description: ${this.description}` + + } +} + +module.exports=Product \ No newline at end of file diff --git a/index.js b/index.js index efad601..fab2c30 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,9 @@ // Import Classes Here - +const Customer = require('./classes/Customer.js') +const Product = require('./classes/Product.js') +const Cart=require(`./classes/Cart.js`)