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 "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 |
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 # 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 |
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) #initialize method | |
| @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 # 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 |
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) | |
| 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
| 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 |
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 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"> |
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 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"> |
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 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"> |
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 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"> |
NewerOlder