Skip to content

Instantly share code, notes, and snippets.

@glenasmith
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glenasmith/a72fa467b4a90031c9fb to your computer and use it in GitHub Desktop.
Save glenasmith/a72fa467b4a90031c9fb to your computer and use it in GitHub Desktop.
A small TypeScript demo for the lightening talk at Canberra JUG
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