From e18cece83ed308565cb51d950a024b72f04cdce8 Mon Sep 17 00:00:00 2001 From: ktinson Date: Mon, 9 Sep 2024 12:03:06 -0500 Subject: [PATCH 1/6] started Product --- classes/Product.js | 17 +++++++++++++++++ index.js | 4 +--- package-lock.json | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/classes/Product.js b/classes/Product.js index e69de29..10fee48 100644 --- a/classes/Product.js +++ b/classes/Product.js @@ -0,0 +1,17 @@ +class Product{ + constructor(name, price, description, instock){ + // constructor(name, price, description, instock){ + this.name=name; + this.price=price; + this.description=description; + // + this.instock=instock; + + } + display(){ + + // console.log(`Name: ${this.name}, Price: ${this.price}, Description: ${this.description}`) + return `Name: ${this.name}, Price: $${this.price}, Description: ${this.description}`} +} +module.exports = Product; + diff --git a/index.js b/index.js index efad601..9381a60 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,6 @@ // Import Classes Here - - - +const Product = require('./classes/Product') diff --git a/package-lock.json b/package-lock.json index 9b68881..5713249 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4717,7 +4717,8 @@ "jest-pnp-resolver": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", - "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==" + "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", + "requires": {} }, "jest-regex-util": { "version": "29.4.3", From d5815524c6deeb9e8025af89127790e4a95bb1bb Mon Sep 17 00:00:00 2001 From: bjjones8512 Date: Mon, 9 Sep 2024 12:25:33 -0500 Subject: [PATCH 2/6] Cart --- classes/Cart.js | 19 +++++++++++++++++++ index.js | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/classes/Cart.js b/classes/Cart.js index e69de29..6fec1c6 100644 --- a/classes/Cart.js +++ b/classes/Cart.js @@ -0,0 +1,19 @@ +class Cart { + constructor() { + this.products = [] + this.total = 0 + } + + addProduct(product) { + this.products.push(product) + this.total += product.price + } + + removeProduct(index) { + if (index >= 0 && index < this.products.length) { + this.total -= this.products[index].price + this.products.splice(index, 1) + } + } +} +module.exports = Cart \ No newline at end of file diff --git a/index.js b/index.js index 9381a60..739aa28 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ // Import Classes Here const Product = require('./classes/Product') - +const Cart = require('./classes/Cart') From 7071ae9e8c6b25f3048bd73a10cbb9ea4bfba049 Mon Sep 17 00:00:00 2001 From: ktinson Date: Mon, 9 Sep 2024 12:32:48 -0500 Subject: [PATCH 3/6] changed to inStock --- classes/Product.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/Product.js b/classes/Product.js index 10fee48..d5f309a 100644 --- a/classes/Product.js +++ b/classes/Product.js @@ -1,11 +1,12 @@ class Product{ - constructor(name, price, description, instock){ + constructor(name, price, description, inStock){ // constructor(name, price, description, instock){ this.name=name; this.price=price; this.description=description; - // - this.instock=instock; + inStock=true; + this.inStock=inStock; + // this.instock=true; } display(){ From e8d28782f7a91a7f40b17457e0ecbb848809f2dc Mon Sep 17 00:00:00 2001 From: ktinson Date: Mon, 9 Sep 2024 12:48:36 -0500 Subject: [PATCH 4/6] removed comments --- classes/Product.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/classes/Product.js b/classes/Product.js index 10fee48..7b76c3c 100644 --- a/classes/Product.js +++ b/classes/Product.js @@ -1,16 +1,12 @@ class Product{ - constructor(name, price, description, instock){ - // constructor(name, price, description, instock){ + constructor(name, price, description, inStock){ this.name=name; this.price=price; this.description=description; - // - this.instock=instock; - + inStock=true; + this.inStock=inStock; } display(){ - - // console.log(`Name: ${this.name}, Price: ${this.price}, Description: ${this.description}`) return `Name: ${this.name}, Price: $${this.price}, Description: ${this.description}`} } module.exports = Product; From 0db985f866f9cc771d4ba76c4e5380446544c5b3 Mon Sep 17 00:00:00 2001 From: Rtollinchi Date: Mon, 9 Sep 2024 14:38:26 -0400 Subject: [PATCH 5/6] completer Customer.js --- classes/Customer.js | 13 +++++++++++++ classes/Product.js | 2 +- index.js | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/classes/Customer.js b/classes/Customer.js index e69de29..4cd2b41 100644 --- a/classes/Customer.js +++ b/classes/Customer.js @@ -0,0 +1,13 @@ +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; diff --git a/classes/Product.js b/classes/Product.js index 0600c42..1ec885d 100644 --- a/classes/Product.js +++ b/classes/Product.js @@ -7,7 +7,7 @@ class Product{ inStock=true; this.inStock=inStock; // this.instock=true; - + } display(){ return `Name: ${this.name}, Price: $${this.price}, Description: ${this.description}`} diff --git a/index.js b/index.js index 739aa28..f1d71a3 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ const Product = require('./classes/Product') const Cart = require('./classes/Cart') - +const Customer = require('./classes/Customer') @@ -44,4 +44,4 @@ try { } } catch(e){ -} \ No newline at end of file +} From baa96800882d606714ec89fd6ef8c023e19c9053 Mon Sep 17 00:00:00 2001 From: bjjones8512 Date: Mon, 9 Sep 2024 13:53:49 -0500 Subject: [PATCH 6/6] Auth --- classes/Auth.js | 17 +++++++++++++++++ index.js | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/classes/Auth.js b/classes/Auth.js index e69de29..b025d8e 100644 --- a/classes/Auth.js +++ b/classes/Auth.js @@ -0,0 +1,17 @@ +const Customer = require("./Customer") + +class Auth { + constructor() { + this.customers = [] + } + + register(name, email, shippingAddress) { + const newCustomer = new Customer(name, email, shippingAddress) + this.customers.push(newCustomer) + } + + login(email) { + return this.customers.find(Customer => Customer.email === email) || null; + } +} +module.exports = Auth diff --git a/index.js b/index.js index f1d71a3..a13f98f 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ const Product = require('./classes/Product') const Cart = require('./classes/Cart') const Customer = require('./classes/Customer') - +const Auth = require('./classes/Auth')