Skip to content

Instantly share code, notes, and snippets.

@Ebonkuab
Ebonkuab / array_of_light2.js
Created February 9, 2016 20:08
javascript code for showing an array of numbers given an input
var ArrayOfLight = function (num) {
var arrayOfNumber = []
var i = 0 ;
var counter = 0;
while (counter <= num){
arrayOfNumber.push(i)
i = i + 1
counter = counter + 1
}
@Ebonkuab
Ebonkuab / roman_numerals.rb
Created January 18, 2016 02:29
ruby code to coNvert arabic (contemporary ) numbers to old style roman numerals. (LIGHTHOUSE WEB DEV BOOTCAMP)
# ROM ={ I: 1,
# V: 5,
# X: 10,
# L: 50,
# C: 100,
# D: 500,
# M: 1000
# }
@Ebonkuab
Ebonkuab / barracks.rb
Created January 13, 2016 22:38
following the TDD concept and using Rspec as the automated testing platform to code A simulation of Warcraft 3 barracks Simulator
#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)
@Ebonkuab
Ebonkuab / two_player_game.rb
Created January 12, 2016 20:56
two player guesing game using OOP ruby ( LIGHTHOUSE WEB DEV BOOTCAMP)
#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
@Ebonkuab
Ebonkuab / contact_list.rb
Created January 12, 2016 18:13
Starter code for the Contact List app
require_relative 'contact'
# Interfaces between a user and their contact list. Reads from and writes to standard I/O.
class ContactList
# TODO: Implement user interaction. This should be the only file where you use `puts` and `gets`.
end
@Ebonkuab
Ebonkuab / classical_inheritance.rb
Created January 11, 2016 22:50
using the inheritance properties of ruby to display different properties for sub-classes (LIGHTHOUSE WEB DEV BOOTCAMP)
class Animal
attr_reader :height , :habitat
def initialize(height, habitat)
@height = height
@habitat = habitat
end
def wakeup (wakeup_sound)
puts " i make this sound #{wakeup_sound} when I wakeup"
@Ebonkuab
Ebonkuab / shakil_the_dog.rb
Created January 8, 2016 21:05
ruby code for interaction with shakil the dog (LIGHTHOUSE DEV BOOTCAMP)
# Save this file to your computer so you can run it
# via the command line (Terminal) like so:
# $ ruby shakil_the_dog.rb
#
# Your method should wait for user input, which corresponds
# to you saying something to your dog (named Shakil).
# You'll probably want to write other methods, but this
# encapsulates the core dog logic
def shakil_the_dog
@Ebonkuab
Ebonkuab / State_info.rb
Created January 8, 2016 17:57
Using ruby code to access data defined in Hashes and implementing them in Methods ( LIGHTHOUSE WEB DEV BOOTCAMP)
@states = {
OR: 'Oregon',
FL: 'Florida',
CA: 'California',
NY: 'New York',
MI: 'Michigan',
TX: 'Texas',
AL: 'Alaska'
}
@Ebonkuab
Ebonkuab / maximum-value.rb
Last active January 9, 2016 00:52
using ruby code to get the maximum value within a one dimensional array (LIGHTHOUSE WEB DEV BOOTCAMP)
# Find the maximum
def maximum(arr)
max = arr[0]
arr.each do |child|
if child > max
max = child
end
end
max
@Ebonkuab
Ebonkuab / Regular_expressions.rb
Created January 8, 2016 00:35
Using Regular expressions (Regex) to select strings to give a true with bolean operations
# Determine whether a string contains a SIN (Social Insurance Number).
# A SIN is 9 digits and we are assuming that they must have dashes in them
#rescue Exception => e
#end
def has_sin?(string)
/^.\w*\s\w*.t\s\w*\s[s-u]\D{3}.\s234\W6?0?4?.(142)[^1,]$/ === string