Skip to content

Instantly share code, notes, and snippets.

@forksofpower
Created June 28, 2018 15:25
Show Gist options
  • Save forksofpower/4c393e1a65ce61d9660cd4fe0fd3d920 to your computer and use it in GitHub Desktop.
Save forksofpower/4c393e1a65ce61d9660cd4fe0fd3d920 to your computer and use it in GitHub Desktop.
class Animal {
    constructor(public name) { }
    move(meters) {
        alert(this.name + " moved " + meters + "m.");
    }
}

class Snake extends Animal {
    constructor(name) { super(name); }
    move() {
        alert("Slithering...");
        super.move(5);
    }
}

class Horse extends Animal {
    constructor(name) { super(name); }
    move() {
        alert("Galloping...");
        super.move(45);
    }
}

var sam = new Snake("Sammy the Python")
var tom: Animal = new Horse("Tommy the Palomino")

sam.move()
tom.move(34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment