added basic functions

This commit is contained in:
Mohammed Ashab Uddin
2020-07-21 13:56:06 +04:00
parent cbe03c5954
commit fc966644ef

View File

@@ -3,11 +3,20 @@ const {Product} = require('./product');
class Website {
/**
* @param {Map<string,string>} details
* @param {Object} details
*/
constructor(details){
this.details = details;
this.products = [];
constructor(companyName){
this.firstName = '';
this.lastName = '';
this.companyName = companyName;
this.logoUrl = '';
this.bannerUrl = '';
this.desc = '';
this.email = '';
//uses key value pair to store product
//key is the productId of the product
//value is the product itself
this.products = {};
}
/**
@@ -15,9 +24,38 @@ class Website {
* @param {Product} product
*/
addProduct(product){
this.products.push(product);
if(this.products[product.id] == undefined)
{
this.products[product.id] = product;
return true
}
return false;
}
/**
*
* @param {string} productId
* @returns {Product}
*/
getProduct(productId){
return this.products[productId];
}
/**
*
* @param {string} productId
*/
deleteProduct(productId){
if(this.products[productId] != undefined)
{
return delete this.products[productId];
}
return false;
}
}
module.exports.Website = Website;