Skip to content

Commit 9c6fcbc

Browse files
committed
#24 - JavaScript
1 parent a1e52a4 commit 9c6fcbc

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed
Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
1-
class Hamburger {
2-
basicIngredients = ['bread roll', 'beef', 'tomato', 'lettuce', 'cheese', 'onion'];
1+
//EJERCICIO
2+
class BasicPizza {
3+
constructor(size) {
4+
this.price = this.pricesList[size];
5+
}
6+
7+
toppings = ['salsa', 'mozzarella', 'pepperoni'];
8+
9+
//Precios en dólares, jajs
10+
pricesList = {
11+
small: '$5.00',
12+
medium: '$9.00',
13+
large: '$12.00',
14+
extralarge: '$16.00',
15+
};
16+
17+
getPrice() {
18+
console.log(this.price);
19+
}
320
}
421

5-
class Cheeseburger extends Hamburger {
6-
constructor() {
7-
super();
8-
this.basicIngredients.push('more cheese');
22+
class HawaianPizza extends BasicPizza {
23+
constructor(size) {
24+
super(size);
25+
this.toppings.push('jamón', 'piña');
26+
this.price = this.pricesList[size];
27+
}
28+
29+
pricesList = {
30+
small: '$6.70',
31+
medium: '$10.50',
32+
large: '$13.50',
33+
extralarge: '$16.30',
34+
};
35+
}
36+
37+
class PizzaDecorator extends BasicPizza {
38+
constructor(pizza) {
39+
super(pizza.size, pizza.toppings);
40+
this.pizza = pizza;
41+
}
42+
43+
getPrice() {
44+
this.pizza.getPrice();
945
}
1046
}
1147

12-
let burger1 = new Hamburger();
13-
console.log(burger1);
48+
let pizza1 = new HawaianPizza('small');
1449

15-
let burger2 = new Cheeseburger();
16-
console.log(burger2);
50+
pizza1.getPrice();

0 commit comments

Comments
 (0)