From 425bc4389caa083b3b42e8b1a6e2bd495f25c568 Mon Sep 17 00:00:00 2001 From: ura-hasam Date: Sun, 1 Sep 2024 15:43:41 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BE=8B=E5=A4=96=E5=87=A6=E7=90=86=E3=81=A8?= =?UTF-8?q?=E3=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/index.js | 15 ++++++--------- src/index.ts | 21 ++++++--------------- 2 files changed, 12 insertions(+), 24 deletions(-) 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