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
#two player maths game using objects | |
# defining the player class | |
class Player | |
attr_accessor :name, :number_of_lives | |
def initialize (name) | |
@name = name | |
@number_of_lives= 3 | |
end |
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
#require_relative 'footman' | |
class Barracks | |
attr_accessor :gold,:food | |
def initialize ( ) | |
# Need to default the 2 instance variables here | |
# Also also give code outside this class access to these variables (via attr_reader, attr_writer or attr_accessor) |
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
# ROM ={ I: 1, | |
# V: 5, | |
# X: 10, | |
# L: 50, | |
# C: 100, | |
# D: 500, | |
# M: 1000 | |
# } |
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 ArrayOfLight = function (num) { | |
var arrayOfNumber = [] | |
var i = 0 ; | |
var counter = 0; | |
while (counter <= num){ | |
arrayOfNumber.push(i) | |
i = i + 1 | |
counter = counter + 1 | |
} |
OlderNewer