Skip to content

Instantly share code, notes, and snippets.

View callanccook's full-sized avatar

Callan Cook callanccook

View GitHub Profile
@callanccook
callanccook / rps.rb
Created March 17, 2017 03:47
3.11 Optional Rock, Paper, Scissors Ruby Project
def choose
puts "Let's play rock, paper, scissors!".downcase
puts "Do you pick rock, paper, or scissors?".downcase
user_choice = STDIN.gets.chomp
comp = rand(3)
if comp == 1
comp_choice = "rock"
elsif comp == 2
comp_choice = "paper"
else comp == 3
@callanccook
callanccook / cat.rb
Created March 2, 2017 02:13
Task 3.5 Self, Class Methods, & Inheritance
class Pet # pet class
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed) # initialize method
@color = color
@breed = breed
@hungry = true
end
# end initialize method
@callanccook
callanccook / cat.rb
Created February 28, 2017 22:44
Task 3.3 Objects & Cats
class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed) #initialize method
@color = color
@breed = breed
@hungry = true
end
@callanccook
callanccook / fav_foods.rb
Created February 27, 2017 23:27
Task 3.3 Ruby Arrays
def fav_foods # defining the method
food_array = [] # code for this method goes here
3.times do
puts "Name favorite food."
food_array << gets.chomp
end
puts "Your favorite foods are #{food_array.join(", ")}."
food_array.each do |food| # do something to each element in food_array; that element is to be referred to as food
puts "I like #{food} too!" # the thing we are doing
end # ends the loop
@callanccook
callanccook / program2.rb
Created February 23, 2017 22:58
Task 3.2 Flow Control
if (5 + 5 == 10)
puts "this is true"
else
puts "this is false"
end
@callanccook
callanccook / program.rb
Created February 23, 2017 18:30
Task 3.1 Intro to Ruby
puts "hello"
puts "hello"
my_name = "Callan"
def greeting # here I defined a method called greeting
puts "Callan:" # here is the code inside my method
name = gets.chomp
puts "Hello" + " " + name
end # here I ended the method
@callanccook
callanccook / index-calculator.html
Created February 17, 2017 22:11
Task 2.11 Interactive Website
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="subject" content="index">
<title>Calculator</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
@callanccook
callanccook / index.html
Created February 16, 2017 00:22
Task 2.10 Google Map API's
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<!-- begin meta -->
<meta name="subject" content="index">
@callanccook
callanccook / index.html
Created February 14, 2017 23:52
Task 2.9 Object Literals
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<!-- begin meta -->
<meta name="subject" content="index">
@callanccook
callanccook / index.html
Created February 14, 2017 00:35
Task 2.8 Arrays, Loops
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<!-- begin meta -->
<meta name="subject" content="index">