Skip to content

Instantly share code, notes, and snippets.

@LucieKla
LucieKla / cat.rb
Last active May 7, 2017 13:20
Cat
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
def fav_foods
food_array = [] # instead of the brackets, you can also use Array.new to make a new empty array
3.times do
puts "Name a favorite food."
food_array << gets.chomp
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
end
puts "Your favorite foods are #{food_array.join(", ")}."
def greeting
puts "Please enter your name:"
name = gets.chomp
puts "Hello" + " " + name
end
greeting
@LucieKla
LucieKla / index.html
Last active May 12, 2017 17:52
Task 1
<!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 -->
<title>Hey, it's me!</title>