Skip to content

Instantly share code, notes, and snippets.

@seogi1004
Created November 27, 2017 14:05
Show Gist options
  • Save seogi1004/dfcec8aa4f9cfee8a2a79c3925e974c5 to your computer and use it in GitHub Desktop.
Save seogi1004/dfcec8aa4f9cfee8a2a79c3925e974c5 to your computer and use it in GitHub Desktop.
var BionicUnit = function(name, type) {
this.name = name;
this.type = type;
this.recovery = function(number) {
$("body").append("'" + this.name + "'의 체력이 " + number + "만큼 재생<br/>");
}
this.move = function(distance) {
$("body").append("1. " + type + " 유닛인 '" + name + "'이(가) " + distance + "만큼 이동<br/>");
}
this.move = function(distance, isGround) {
if(isGround && type == "지상") {
$("body").append("2. " + type + " 유닛인 '" + name + "'이(가) " + distance + "만큼 이동<br/>");
} else {
$("body").append("2. " + type + " 유닛인 '" + name + "'은(는) 언덕 위로 바로 이동할 수 없습니다.<br/>");
}
}
}
// ...
// ...
$(function() {
BionicUnit.prototype = new Unit;
// -- 1. 유닛 생성
var unit1 = new BionicUnit("마린");
// -- 2. 지상을 10만큼 이동
unit1.move(10);
// -- 3. 언덕 위를 50만큼 이동
unit1.move(50, true);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment