This file contains 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 Dice | |
attr_accessor :sides | |
def initialize | |
self.sides = (1..6).to_a | |
end | |
def roll | |
sides.sample |
This file contains 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
sqlite3 classroom.sqlite3 | |
CREATE TABLE students (id INTEGER, first_name TEXT, last_name TEXT) | |
INSERT INTO students (id, first_name, last_name) VALUES (1,"Ben","Doane"),(2,"Ben","Barnett"),(3,"Matt","Fair"),(4,"Angie","Martaus"),(5,"Lauren","Imhoff"),(6,"Shirley","Grigsby"),(7,"Anna","Lioubimova"),(8,"Michelle","Caudle"); | |
sqlite> SELECT * FROM students; | |
1|Ben||Doane | |
2|Ben||Barnett | |
3|Matt||Fair |
This file contains 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 "blackjack_cards" | |
require_relative "blackjack_deck" | |
class Blackjack | |
attr_accessor :player_hand, :computer_hand, :p_score, :c_score, :bjdeck, :shoe | |
def initialize | |
puts "Welcome to Blackjack, sir. Please press [Enter] to deal." | |
STDIN.gets |
This file contains 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 Cards | |
attr_accessor :suit, :face, :value | |
def initialize(face, suit) | |
self.face = face | |
self.suit = suit | |
if face == "Ace" | |
self.value = 14 | |
elsif face == "King" |
This file contains 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 Game | |
attr_accessor :player_one_choice, :computer, :computer2, | |
def initialize | |
puts "Let's play Rock, Paper, Scissors!" | |
end | |
def reset(computer_wins=0,user_wins=0) | |
vs_user(computer_wins,user_wins) |
This file contains 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
#Homework - Day 4 | |
#NORMAL MODE | |
#Good news Rubyists! | |
#We have a week of records tracking what we shipped at Planet Express. | |
#I need you to answer a few questions for Hermes. | |
#How much money did we make this week? | |
require 'csv' | |
week_total = [] |
This file contains 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
# Homework - Day 3 | |
# NORMAL MODE----------------------------------------------- | |
# Define a robot class. A robot should have a name | |
class Robot | |
attr_accessor :name | |
attr_accessor :height | |
#creat a robot instance method for saying "hi" | |
def say_hi | |
puts "Greetings" |
This file contains 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
[1] pry(main)> our_class=["Ben","Anna","Shirley","Lauren","Ben","Michelle","Angie","Matt"] | |
=> ["Ben", "Anna", "Shirley", "Lauren", "Ben", "Michelle", "Angie", "Matt"] | |
[6] pry(main)> our_class.each do |name| | |
[6] pry(main)* if name.length<5 | |
[6] pry(main)* less_than5 << name | |
[6] pry(main)* end | |
[6] pry(main)* end | |
=> ["Ben", "Anna", "Shirley", "Lauren", "Ben", "Michelle", "Angie", "Matt"] | |
[7] pry(main)> less_than5 |
This file contains 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
lipsum_wanted = ARGV[0].dup if ARGV[0] | |
paragraphs_wanted = ARGV[1].dup if ARGV[1] | |
if lipsum_wanted | |
lipsum_wanted.downcase! | |
end | |
paragraphs_wanted= paragraphs_wanted.to_i | |
if paragraphs_wanted<1 |