Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Gh pages #54

Open
wants to merge 3 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion js/super_hero.js
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
// var SuperHero = ...
var SuperHuman = function(name){
this.name = name;
this.health = 100;
}

SuperHuman.prototype.doublepunch = function(opp1, opp2) {
this.health -= 3
opp1.health -= 10;
opp2.health -= 5;
document.write(this.name + " has superpunched both " + opp1.name + " and " + opp2.name + "</br>")
}


SuperHuman.prototype.attack = function(opp) {
opp.health -= 10;
this.health -= 5;
document.write(this.name + " just hit " + opp.name + "</br>")
document.write(this.name + " used 5 energy and has " + this.health + " left." + "</br>")
document.write(opp.name + " loses 10 energy and has " + opp.health + " left." + "</br>" + "</br>")
}

var SuperHero = function(name) {
SuperHuman.call(this)
this.type = "a hero"
this.name = name;
}

SuperHero.prototype = Object.create(SuperHuman.prototype)

SuperHero.prototype.heal = function(){
this.health += 8
document.write(this.name + " has used healing power and now has " + this.health + " health </br>")
}

function SuperVillian(name) {
SuperHero.call(this)
this.type = "a villain"
this.name = name
}

SuperVillian.prototype = Object.create(SuperHuman.prototype)


var batman = new SuperHero("batman");
var superman = new SuperHero("superman")
var joker = new SuperVillian("joker")

batman.attack(joker)
joker.attack(superman)
superman.heal()
joker.doublepunch(batman, superman)

document.write( "</br>" + "health results:" + "</br>")

document.write(batman.name + " is " + batman.type + " and has " + batman.health + " health left." + "</br>")
document.write(superman.name + " is " + superman.type + " and has " + superman.health + " health left." + "</br>")
document.write(joker.name + " is " + joker.type + " and has " + joker.health + " health left." + "</br>")
6 changes: 6 additions & 0 deletions js/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ QUnit.test("hello test", function(assert) {
assert.strictEqual(1 + 1, 2, "One plus one is two");
});


QUnit.test("health matches", function(assert) {
assert.strictEqual(superman.health, superman.health , "health matches");
});


// ADD TESTS HERE