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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Favorite Dives</title> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
</head> | |
<body> | |
<header> | |
<h1 id="page-title">My Favorite Dive Restaurants</h1> |
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_relative "cup" | |
class Mojo < Cup | |
def initialize | |
super | |
puts "Welcome to Mojo Coffee" | |
end | |
end |
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 Cup # use title case for classes and only classes | |
# Have to call it "initialize" for it to work | |
def initialize | |
puts "I'm alive! **SPARKLE**" | |
# This is an instance variable - all cups have independent drink_amounts | |
# Pretend like these are percentages | |
@drink_amount = 0 | |
end |
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
# Pop trivia app | |
questions_answers = { | |
"Who sang Material Girl?" => "madonna", | |
"Which actor played Zoolander?" => "ben stiller", | |
"Who is not Michael Jackson's lover?" => "billie jean" | |
} | |
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" | |
puts " Welcome to Sia's Really Cool Trivia App" |
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
# Pop trivia app | |
questions = [ | |
"Who sang Material Girl?", | |
"Which actor played Zoolander?", | |
"Who is not Michael Jackson's lover?"] | |
# store them in lowercase to make checking answers easier | |
answers = [ | |
"madonna", |
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
# All about loops in Ruby | |
# For loop - not really used in Ruby! | |
# for n in 1..100 | |
# puts "#{n} birds on a wire - AH AH AH" | |
# end | |
# While and until loops - used when it's unclear how many times we need to loop | |
# understands_loops = "no" |
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 division | |
puts "Give me an integer!" | |
integer1 = gets.chomp.to_i | |
puts "Give me another integer!" | |
integer2 = gets.chomp.to_i | |
if integer2 == 0 | |
puts "Sorry, can't divide by zero!" | |
# Instead of just ending the method, we can call it again from inside itself! This is known as recursion. |
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
todays_temp = 80 | |
weather_condition = "sunny" | |
def activity(temp, condition="sunny") | |
if temp == 80 && condition == "sunny" | |
puts "That's the perfect temp! Let's still go hiking." | |
elsif temp > 50 && condition == "sunny" | |
puts "I'm going hiking!" | |
else | |
puts "Let's read a book." |
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 greeting name="Sia" | |
puts "Hello #{name}" | |
end | |
def how_you_doing(name1, name2) | |
puts "Hi, I'm #{name1}. How YOU doin', #{name2}?" | |
end | |
greeting("Sia") | |
greeting("Lindsay") |
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
# Imperial to Metric conversion program | |
puts "*************************************************" | |
puts "*** Welcome to My Fancy Conversion Program! ***" | |
puts "*************************************************\n\n" | |
puts "What's your name?" | |
user = gets.chomp | |
puts "\nWhat is your height in inches?" | |
user_height_inches = gets.chomp.to_i |