Challenge: Solution Review
This lesson will explain the solution to the problem from the previous coding challenge.
We'll cover the following...
We'll cover the following...
Solution #
Explanation
The program simply displays information about the items in the shopping cart. As discussed, it is divided into three components:
-
The shopping cart object is represented by the model
ShoppingCartModel -
The information about the items in the cart is displayed by the view component
ShoppingCartView -
The model and view components are connected through the controller
ShoppingCartController
Let’s take a look at each component one by one.
ShoppingCartModel
class ShoppingCartModel
{
constructor(itemNumber,itemName, itemQuantity, itemPrice){
this.itemName = itemName;
this.itemQuantity = itemQuantity;
this.itemPrice = itemPrice;
this.itemNumber = itemNumber
}
getItemName(){
return this.itemName;
}
getItemQuantity(){
return this.itemQuantity
}
getItemPrice(){
return this.itemPrice;
}
getItemNumber(){
return this.itemNumber;
}
}
The ShoppingCartModel presents a shopping cart object which has the ...