Popcorn Hack #1

Create a child class of the class Appliance, and call it’s name() function

%%js 
    class Appliance {
        constructor(Mmb) {
            this.Mmb = Mmb;
        }
        name() {
            return "I am a " + this.constructor.Mmb + " and my model is " + this.Mmb;
        }
    }
    // Below this name the class and cause it to inherit from the Appliance class
    class Mmb extends Appliance{
        constructor(Mmb) {
            super(Mmb);
            console.log(this.Mmb)
    }
        
    }
<IPython.core.display.Javascript object>

Popcorn Hack #2

Create child classes of the product class with items, and add parameters depending on what it is. An example is provided of a bagel.

%%js
    class Product{
        constructor(price,mold,taxRate) {
            this.price = price;
            this.mold = mold;
            this.taxRate = taxRate;
        }   
        getPrice() {
            return this.price + this.taxRate * this.price;
        }
        product(){
            const className = this.constructor.name.toLowerCase();
            // Does not use and assuming that more parameteres will be added
            return "You are ordering an " + className + " with a price of " + this.getPrice() + " dollars, mold percentage of " + this.mold + "%";
        }
    }
    class Apple extends Product{
        constructor(price, mold, taxRate, flavor) {
            super(price, mold, taxRate);
            this.flavor = flavor;
        }
        getPrice(){
            return super.getPrice() * this.mold;
        }
        product(){
            return super.product() + " and a flavor of " + this.flavor;
        }
    }
var sourApple = new Apple(11, 4, 0.31, "Sour");
console.log(sourApple.product());
<IPython.core.display.Javascript object>