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 Pet | |
| attr_reader :color, :breed | |
| attr_accessor :name | |
| def initialize(color, breed) | |
| @color = color | |
| @breed = breed | |
| @hungry = true | |
| 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 Cat | |
| attr_reader :color, :breed | |
| attr_accessor :name | |
| def initialize(color, breed) | |
| @color = color | |
| @breed = breed | |
| @hungry = true | |
| 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
| def fav_foods | |
| food_array = [] | |
| 3.times do | |
| puts "Name a favorite food." | |
| food_array << gets.chomp | |
| end | |
| p food_array | |
| puts "You favorite foods are #{food_array.join(", ")}" | |
| food_array.each do |food| | |
| puts "I like #{food} too" |
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
| # number = 0 | |
| # while (number <= 10) do | |
| # p "the number is now #{number}" | |
| # number += 1 | |
| # end | |
| (0..10).each do |n| | |
| p "the new number is #{n}" | |
| 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
| def choose | |
| puts "Do you like programming? Yes, no or maybe please." | |
| choice = gets.chomp | |
| case choice.downcase | |
| when "yes" | |
| puts "That\'s Awesome!" | |
| when "no" | |
| puts "That\'s to bad, time to quit!" | |
| when "maybe" | |
| puts "That\'s ok, it will get better." |
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
| #if (5+5=10) | |
| if true | |
| puts "this is true" | |
| else | |
| puts "this is false" | |
| 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
| my_name = "Batman" | |
| def greeting(name) | |
| p "hello" + " " + name | |
| end | |
| greeting("Craig") | |
| greeting(my_name) | |
| def greeting | |
| puts "Enter your name here:" |
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
| window.onload = function() { | |
| var current, | |
| screen, | |
| output, | |
| limit, | |
| zero, | |
| period, | |
| operator; | |
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> | |
| <meta charset="UTF-8"> | |
| <title>Calculator</title> | |
| <link rel="stylesheet" href="css/style.css"> | |
| </head> |
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
| body { | |
| background:#fff; | |
| } | |
| #background { | |
| width:300px; | |
| height:400px; | |
| background:gray; | |
| margin:50px auto; | |
| } |
NewerOlder