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
public class LivingThing { | |
public String name; | |
public int health; | |
public int magicPoints; | |
public String attack; | |
public LivingThing(String name, int health, int magicPoints, String attack) { | |
this.name = name; | |
this.health = health; | |
this.magicPoints = magicPoints; |
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
monsters = [{"name":"Goblin", "health":20, "magicPoints":0, "attack":"Dagger"}, | |
{"name":"Dragon", "health":300, "magicPoints":200, "attack":"Fireball"}, | |
{"name":"Orc", "health":40, "magicPoints":0, "attack":"Sword"}] |
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
monsterName = ["Dragon", "Goblin"] | |
monsterHealth = [300, 18] | |
monsterMagicPoints = [200, 0] | |
monsterAttack = ["Dagger", "Fireball", "Sword"] |
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 vanquishMonster(monsterIndex) { | |
remove(monsterName, monsterIndex); | |
remove(monsterHealth, monsterIndex); | |
remove(monsterMagicPoints, monsterIndex); | |
# Note there is no remove for monsterAttack | |
} | |
vanquishMonster(0); |
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
var monsterName = ["Goblin", "Dragon", "Orc"]; | |
var monsterHealth = [20, 300, 40]; | |
var monsterMagicPoints = [0, 200, 0]; | |
var monsterAttack = ["Dagger", "Fireball", "Sword"]; | |
print(monsterName[0] + " has " + monsterHealth[0] + " hit points"); | |
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
var heroName = "Elsa"; | |
var heroHealth = 50; | |
var heroMagicPoints = 80; | |
var heroAttack = "Axe"; | |
var monsterName = "Goblin"; | |
var monsterHealth = 20; | |
var monsterMagicPoints = 0; | |
var monsterAttack = "Dagger"; |
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
var name = "Elsa"; | |
var health = 50; | |
var magicPoints = 80; | |
var attack = "Axe"; | |
print(name + " has " + health + " hit points"); |
NewerOlder