Skip to content

Instantly share code, notes, and snippets.

View troyleach's full-sized avatar
💭
😃

Troy troyleach

💭
😃
View GitHub Profile
@troyleach
troyleach / gist:20695c20e9dc2c0fcc55
Created January 21, 2015 22:24
screen cast 18, 19, and 20
#screen cast 18, 19 and 20
# So I combined all these, I hope that is ok!!
=begin
Create a class called Person.
Add methods to it that let you change the person’s age, occupation, and mood.
Then add methods named age, occupation, and mood which give return values of the age, occupation, and mood respectively.
Then add a method that nicely displays a summary of the person’s info, including the age, occupation, and mood.
#screen cast 17
class Calculator
include Math
def add(num1, num2)
num1 + num2
end
#screen cast 16
# so I guess I @cheated!!
class Car
def new_car
@mercedes = []
end
def engine
@troyleach
troyleach / gist:d5b118f0c5e48a754041
Created January 21, 2015 22:18
screen cast 13 and 14
class Person
def musical_instruments
instrument = Drums.new
puts "I own a #{instrument.size} #{instrument.set_name} set of drums"
end
def own_a_dog
milo = Dog.new
"My dogs name is #{milo.name}"
@troyleach
troyleach / gist:881d756dfb78be90311b
Last active August 29, 2015 14:13
screencast 12
#screen cast 13
state_capitals = { "Colorado" => "Denver",
"Kentucky" => "Frankfort",
"Illinois" => "Springfield",
"Minnesota" => "Saint Paul",
"Mississippi" => "Jackson" }
puts "I can tell you the capital of any of these states:"
state_capitals.each { |key, _| puts key }
#screen cast 11
puts "Please enter 5 words, any words"
words = []
number = 0
5.times do
puts "Enter word number #{number += 1}"
words << gets.chomp
end
words.each_with_index do |word, index|
puts index.even? ? word.upcase : word
#screencast #10
# puts "Please enter a word, any word"
# word = gets.chomp
# word = word.split("")
# puts word.shuffle
=begin
# => Create a program that asks a user to enter four random words, one at a time. Then,
# => the computer will ask the user to choose a number between 1 and 4.
# => The computer will then display the word corresponding to the correct number.
For example, if the user typed in the words ghost, umbrella, candy, and pepperoni in that order, if the user then chooses the number 2, the computer displays the second word, which in this example is umbrella.
=end
#screencast 9
# puts "Please enter 4 random words, any words"
# This is the basic game. I feel as if this is a total hack job at the moment. BUT it all works
# I will spend free time to refactor and make it better piece of code for sure.
# for this to run there are two other files that are needed these can be found on my git hub.
# https://github.com/troyleach/Connect-Four
require_relative 'player'
@board = Array.new(6, Array.new(7, "-"))
@troyleach
troyleach / gist:a70f377bd4157d85a2a1
Created January 19, 2015 02:10
Screen cast 6 - ask 3 questions!
# => Ask the user a total of three ruby questions.
# => the user will have 3 try's at the question before it moves onto the next question, OR the short game ends.
# => might have gone a little over board with this... oops
class Questions