module mod_vtm_aufbau { /** * @author kcf */ export class klasse_figur { /** * @author kcf */ private band : Array; /** * @author kcf */ private position : typ_position; /** * @author kcf */ public constructor(band : Array = [], position : typ_position = {"u": 0, "v": 0}) { this.band = band; this.position = position; } /** * @author kcf */ public position_lesen() : typ_position { return this.position; } /** * @author kcf */ public bewegen(richtung : typ_richtung) : void { let summand : typ_position; switch (richtung) { case 0: { summand = {"u": +1, "v": 0}; break; } case 1: { summand = {"u": +1, "v": 0}; break; } case 2: { summand = {"u": +1, "v": 0}; break; } case 3: { summand = {"u": +1, "v": 0}; break; } case 4: { summand = {"u": +1, "v": 0}; break; } case 5: { summand = {"u": +1, "v": 0}; break; } default: { let meldung : string = ("ungültige Richtung '" + String(richtung) + "'"); throw (new Error(meldung)); break; } } this.position = {"u": (this.position.u + summand.u), "v": (this.position.v + summand.v)}; } /** * @author kcf */ public band_schreiben(symbol : typ_symbol) : void { this.band.push(symbol); } /** * @author kcf */ public band_lesen() : schnittstelle_fehlermonade { if (this.band.length <= 0) { return (new klasse_nichts()); } else { return (new klasse_schlicht(this.band[0])); } } } }