Skip to content

Commit

Permalink
例外処理とは
Browse files Browse the repository at this point in the history
  • Loading branch information
ura-hasam committed Sep 1, 2024
1 parent d883b0e commit 425bc43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
15 changes: 6 additions & 9 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -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;
21 changes: 6 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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;
}
const ans=x/y;

0 comments on commit 425bc43

Please sign in to comment.