diff --git a/js/index.js b/js/index.js index 52d8f55..32f1aeb 100644 --- a/js/index.js +++ b/js/index.js @@ -1,11 +1,8 @@ "use strict"; -// 復習問題10-1 抽象クラスの作成,10-2 -class Zukei { +const x = 5; +const y = 0; +if (y === 0) { + //yが0のときは例外をスローしてプログラムを終了 + throw new Error("ゼロで割り算はできません"); } -class Eclipse extends Zukei { - Draw() { - console.log("楕円を描画します"); - } -} -const ep = new Eclipse; -ep.Draw; +const ans = x / y; diff --git a/src/index.ts b/src/index.ts index a2ac8eb..4ffbb30 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,18 +1,9 @@ -// 復習問題10-1 抽象クラスの作成,10-2 -abstract class Zukei{ - abstract Draw():void; -} +const x:number=5; +const y:number=0; -class Eclipse extends Zukei{ - Draw(): void { - console.log("楕円を描画します"); - } +if(y===0){ + //yが0のときは例外をスローしてプログラムを終了 + throw new Error("ゼロで割り算はできません"); } -const ep= new Eclipse; -ep.Draw; - -//インターフェイスの作成 -interface Telephone{ - call():void; -} \ No newline at end of file +const ans=x/y; \ No newline at end of file