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 arrayOfLight(x){ | |
var output = []; | |
for (i = 0; i < x +1; i++){ | |
output.push(i); | |
} | |
return output; | |
} |
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
SELECT isbn FROM editions | |
where publisher_id = 59 |
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
class Barracks | |
attr_reader :gold, :food | |
def initialize | |
@gold = 1000 | |
@food = 80 | |
@footman_training_gold = 135 | |
@footman_training_food = 2 | |
@peasant_training_gold = 90 |
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
Regarding the self convention, within both a class method, and the class itself, 'self' refers to the given class, however when called | |
within an instance method, self refers to a specific instance of that class. |
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 './animals_module' | |
module CanFly | |
def fly | |
puts "I'm a #{self.class.name}, and I can fly" | |
end | |
end | |
class Animal |
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
### SETUP | |
require 'rspec' | |
### LOGIC (fix me) | |
class HelloWorld | |
def hello | |
@hello | |
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
### SETUP | |
require 'rspec' | |
### LOGIC (fix me) | |
class HelloWorld | |
def hello | |
@hello | |
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
# You've just been hired at Lighthouse Markets, a reputable (and thoroughly fictional) grocery store chain. | |
# One of the primary features of Lighthouse Markets is their recycling program on pop bottles. Here is how the program works: | |
# For every two empty bottles, you can get one free (full) bottle of pop | |
# For every four bottle caps, you can get one free (full) bottle of pop | |
# Each bottle of pop costs $2 to purchase | |
# Given these parameters, write a program so that you can figure out how many total bottles of pop can be redeemed given a customer investment. | |
p 'Welcome to Lighthouse Pop Bottle Recycling Program, Bottles are $2 each, how many would you like to purchase?' | |
init_investment = gets.chomp.to_i |
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
# Create a 2-player guessing game where players take turns to answer simple addition problems. | |
#The math questions are automatically generated. | |
#It should do this by picking two numbers between 1 and 20. | |
# Example prompt: "Player 1: What does 5 plus 3 equal?" | |
# Both players start with 3 lives. They lose a life if they mis-answer a question. | |
#If a player gets a question wrong, the game should output the new scores for both players, so players know where they stand. | |
# The game doesn’t end until one of the players loses all their lives. | |
#At this point, the game should announce who won and what the other player’s score is. | |
# As before, you can use gets.chomp to get input from users and puts for output. |
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
# Player Class | |
# You will have a Player class, where you will put all of your Player-specific logic and properties. | |
# Your program will still have to keep track of whose turn it is, and check players' scores and lives. | |
# Methods | |
# Your Player class should have instance methods for the following tasks: | |
# gain a point | |
# lose a life |
NewerOlder