Last active
July 1, 2016 10:42
-
-
Save ksakae1216/9f8e5ccb43b3d25093d6c1cbfc5c72e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//敵を作る | |
function Teki(){ | |
this.hp = 100; | |
} | |
//ドラゴンを作る | |
function Dragon(){ | |
Teki.apply(this,arguments); | |
} | |
Dragon.prototype = new Teki; | |
//攻撃してHPを教えてもらう | |
Dragon.prototype.attack = function(){ | |
console.log("ドラゴンの攻撃! ドラゴンのHPは"+this.hp+"だ!"); | |
}; | |
var boss = new Dragon(); //インスタンスをつくる | |
boss.attack(); //攻撃してもらう | |
//出力結果 | |
ドラゴンの攻撃! ドラゴンのHPは100だ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment