From 18d6d7d7de5c07114e60cd6d0ecddb2fc5e06912 Mon Sep 17 00:00:00 2001 From: elainegt20 Date: Mon, 22 Apr 2024 15:47:52 -0400 Subject: [PATCH 1/4] Completed product class --- classes/Product.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 From c4e76be62acd05c2c6af6040468ae9fb853ce5ae Mon Sep 17 00:00:00 2001 From: rxshellg Date: Mon, 22 Apr 2024 17:15:23 -0400 Subject: [PATCH 2/4] Completed cart class --- classes/Cart.js | 16 ++++++++++++++++ index.js | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) 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/index.js b/index.js index efad601..c5223ff 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ // Import Classes Here - - +const Product=require('./classes/Product.js') +const Cart=require(`./classes/Cart.js`) From 3a7b16d32775003eebdd071e714526391df6b980 Mon Sep 17 00:00:00 2001 From: elainegt20 Date: Mon, 22 Apr 2024 18:22:41 -0400 Subject: [PATCH 3/4] Completed Customer class --- classes/Customer.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 From 2ee0061846a403fb86c7e0786b296eec0e061f03 Mon Sep 17 00:00:00 2001 From: elainegt20 Date: Mon, 22 Apr 2024 18:23:53 -0400 Subject: [PATCH 4/4] Imported Customer class --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index efad601..0d76397 100644 --- a/index.js +++ b/index.js @@ -2,8 +2,8 @@ - - +const Customer = require('./classes/Customer.js') +const Product = require('./classes/Product.js')