Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Doane bendoane

View GitHub Profile
@bendoane
bendoane / dice. rb
Created Oct 14, 2015
Homework: day 7
View dice. rb
class Dice
attr_accessor :sides
def initialize
self.sides = (1..6).to_a
end
def roll
sides.sample
@bendoane
bendoane / SQLite work
Created Nov 2, 2015
week 5 day 1 - SQLite work
View SQLite work
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
@bendoane
bendoane / blackjack.rb
Last active Oct 19, 2015
Homework: Weekend 2
View blackjack.rb
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
@bendoane
bendoane / cards.rb
Created Oct 16, 2015
Homework: day 8
View cards.rb
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"
@bendoane
bendoane / Rochambeau
Created Oct 12, 2015
Homework: day 6
View Rochambeau
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)
@bendoane
bendoane / Homework_day4.rb
Created Oct 12, 2015
Planet Express Reporting
View Homework_day4.rb
#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 = []
View homework_day3.rb
# 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"
@bendoane
bendoane / homework_day2
Created Oct 7, 2015
Homework: Array Play
View homework_day2
[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
@bendoane
bendoane / lipsum_generator.rb
Created Oct 6, 2015
Week One, Day One: Generate some lipsum
View lipsum_generator.rb
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