This file contains hidden or 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 arrayOfLight(x) { | |
| var arr = []; | |
| var i = 0; | |
| while (x--) { | |
| arr.push(i++); | |
| } | |
| return arr; | |
| } |
This file contains hidden or 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
| class Comment | |
| attr_reader :user_name, :comment | |
| def initialize(user_name, comment) | |
| @user_name = user_name | |
| @copy = copy | |
| end | |
| def to_s |
This file contains hidden or 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
| class SiegeEngine < Unit | |
| attr_reader :health_points, :attack_points | |
| def initialize | |
| super(400, 50) | |
| end | |
| def attack_barracks(barrack) | |
| barrack.damage(@attack_points * 2) |
This file contains hidden or 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
| class Question | |
| attr_accessor :num1, :num2, :answer | |
| attr_reader :random_operator | |
| def initialize | |
| @num1 = rand(1..100) | |
| @num2 = rand(1..100) | |
| @operator = ['+', '-', '*'] | |
| @random_operator = @operator.sample |
This file contains hidden or 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 'colorize' | |
| @player1_lives = 3 | |
| @player2_lives = 3 | |
| @current_player = 1 | |
| def begin_round | |
| @num_1 = rand(1..100) | |
| @num_2 = rand(1..100) |
This file contains hidden or 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
| def merge_sort(array) | |
| return array if array.length <= 1 | |
| left = merge_sort array[0, array.length / 2] | |
| right = merge_sort array [array.length / 2, array.length] | |
| merge(left, right) | |
| end | |
| def merge(left, right) | |
| result = [] |
This file contains hidden or 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 'pg' | |
| class Contacts | |
| attr_accessor :firstname, :lastname, :email | |
| attr_reader :id | |
| def initialize(firstname, lastname, email, id=nil) | |
| @firstname = firstname | |
| @lastname = lastname |
This file contains hidden or 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
| 1. | |
| heroku-postgres-fe6007ec::CHARCOAL=> | |
| SELECT p.id, e.isbn, p.name | |
| FROM publishers | |
| AS p JOIN editions | |
| AS e ON e.publisher_id = p.id | |
| WHERE p.name = 'Random House'; | |
| id | isbn | name |
This file contains hidden or 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
| puts "What is the height?" | |
| user_input_height = gets.chomp.to_i | |
| puts "What is the width?" | |
| user_input_width = gets.chomp.to_i | |
| puts "How many colours?" | |
| user_input_colour = gets.chomp.to_i | |
| squarefeet = user_input_height * user_input_width |
This file contains hidden or 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 './animal.rb' | |
| class Amphibian < Animal | |
| end |
NewerOlder