Last active
August 29, 2015 14:15
-
-
Save glenasmith/a72fa467b4a90031c9fb to your computer and use it in GitHub Desktop.
A small TypeScript demo for the lightening talk at Canberra JUG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Voting { | |
export interface Voter { | |
votes : number; | |
castVote() : void; | |
} | |
class VotingMachine implements Voter { | |
constructor(public votes : number = 0) { | |
} | |
castVote() : void { | |
this.votes++; | |
} | |
} | |
export class DodgyVotingMachine extends VotingMachine { | |
castVote() { | |
super.castVote(); | |
this.votes+= 100; | |
} | |
} | |
} | |
var vm : Voting.Voter = new Voting.DodgyVotingMachine(); | |
vm.castVote(); | |
document.write("<h1>Glen's Vote count is: " + vm.votes); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment