-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFoodStall.js
67 lines (56 loc) · 1.85 KB
/
FoodStall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { POS } from './POS.js';
export class FoodStall {
constructor(image) {
this.posSystem = new POS();
this.image = image; // Bild des Imbissstands
}
getImage() {
return this.image;
}
getPos() {
return this.posSystem
}
// Produkte hinzufügen
addProductToInventory(product, quantity, purchasePrice) {
this.posSystem.addProductToInventory(product, quantity, purchasePrice);
}
// Produkt in den Warenkorb legen
addToCart(productId, quantity, context = {}) {
try {
this.posSystem.addToCart(productId, quantity, context);
} catch (error) {
console.warn(`Fehler beim Hinzufügen zum Warenkorb: ${error.message}`);
}
}
// Produkt aus dem Warenkorb entfernen
removeFromCart(productId, quantity) {
try {
this.posSystem.removeFromCart(productId, quantity);
} catch (error) {
console.warn(`Fehler beim Entfernen aus dem Warenkorb: ${error.message}`);
}
}
// Rechnung erstellen
generateInvoice(customerInfo, context = {}) {
const total = this.posSystem.calculateTotal();
const margin = this.posSystem.calculateMargin();
const invoice = this.posSystem.checkout('FoodStall', customerInfo, 'Retail Sale');
console.log('Rechnung generiert:', invoice);
console.log('Gesamtsumme:', total, '€');
console.log('Marge:', margin);
return invoice;
}
// Warenkorb anzeigen
listCart() {
return this.posSystem.listCart();
}
// Logbuch anzeigen
getLogbook() {
return this.posSystem.getLogbook();
}
}
export const foodStalls = [
new FoodStall('./img/foodstalls/imbiss_eisladen.png'),
new FoodStall('./img/foodstalls/imbiss_lustig.png'),
new FoodStall('./img/foodstalls/imbiss_rostig.png'),
]