7-1/ class 연습 2017-11-23 typeScript 연습문제 1아래 자바스크립트를 타입스크립트로 바꾸시오 123456789101112131415161718function Car(name) { this.name = name; this.speed = 0; this.honk = function() { console.log("부우우웅"); }; this.accelerate = function(speed) { this.speed = this.speed + speed; }}var car = new Car("BENZ");car.honk();console.log(car.speed);car.accelerate(10);console.log(car.speed); 1차 123456789101112131415161718class Car { constructor(public name: string) { } public speed: number = 0 public honk(): void { console.log('부우우웅') } public accelerate(speed) { this.speed = this.speed + speed; } }const car = new Car("BENZ");car.honk();console.log(car.speed);car.accelerate(10);console.log(car.speed); 2차 12345678910111213141516171819202122class Car { constructor(private name: string) { } private _speed: number = 0 public honk(): void { console.log('부우우웅') } public accelerate(speed) { this._speed = this.speed + speed; } get speed(): number { return this._speed; }}const car = new Car("BENZ");car.honk();console.log(car.speed);car.accelerate(10);console.log(car.speed); 3차 123456789101112131415161718192021222324252627interface ICar { honk(): void; accelerate(speed: number): void }class Car { constructor(private name: string) { } private _speed: number = 0 public honk(): void { console.log('부우우웅') } public accelerate(speed) { this._speed = this._speed + speed; } get speed(): number { return this._speed; }}const car = new Car("BENZ");car.honk();console.log(car.speed);car.accelerate(10);console.log(car.speed);