buyProduct(customer_id, product, count){
// Add your code here
const cafeProduct = [Link]((p) => {
return [Link] === [Link];
});
if (!cafeProduct) {
return false;
}
if (count > [Link]) {
return false;
}
[Link] -= count;
[Link] += [Link] * count;
let customerProduct = this.customer_products.find((cp) => {
return cp.customer_id === customer_id && [Link] ===
[Link];
});
if (customerProduct) {
[Link] += count;
} else {
this.customer_products.push(new CustomerProducts(customer_id, product,
count));
}
return true;
returnProduct(customer_id, product, count){
// Add your code here
const customerProductIndex = this.customer_products.findIndex((cp) => {
return cp.customer_id === customer_id && [Link] ===
[Link];
});
if (customerProductIndex === -1) {
return false;
}
const customerProduct = this.customer_products[customerProductIndex];
if (count > [Link]) {
return false;
}
const cafeProduct = [Link]((p) => {
return [Link] === [Link];
});
if (!cafeProduct) {
return false;
}
[Link] += count;
[Link] -= [Link] * count;
[Link] -= count;
if ([Link] === 0) {
this.customer_products.splice(customerProductIndex, 1);
}
return true;
}
getCurrentBalance(){
// get the current balance at cafe
return [Link];
}