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 'bigdecimal' | |
require 'bigdecimal/util' | |
puts 'What is the amount due?' | |
total = gets.chomp.to_f | |
puts 'What is the amount tendered?' | |
cash = gets.chomp.to_f | |
if total > cash | |
puts 'WARNING: Customer still owes $0.50! Exiting...' |
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 'bigdecimal' | |
require 'bigdecimal/util' | |
values = [] | |
puts 'What is the sale price?' | |
print '>' | |
input = gets.chomp | |
while input != 'done' |
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 'csv' | |
require 'pry' | |
def return_sku (hash, number) | |
answer = hash.first(number) | |
return answer[-1][0] | |
end | |
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
def find_average scores | |
sum = 0.0 | |
scores.each do |x| | |
sum += x | |
end | |
return sum/scores.length | |
end | |
def find_max scores | |
answer = 0 |
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
SELECT title, rating FROM movies ORDER BY rating LIMIT 50; | |
SELECT title FROM movies WHERE rating = 0 ORDER BY title; | |
SELECT title FROM movies WHERE synopsis LIKE '%thrilling%'; | |
SELECT movies.title, movies.year, movies.rating FROM movies JOIN genres ON movies.genre_id = genres.id WHERE genres.name = 'Science Fiction & Fantasy' AND year BETWEEN 1980 AND 1989 ORDER BY rating DESC; | |
SELECT actors.name, movies.title, movies.year FROM movies | |
JOIN cast_members ON movies.id = cast_members.movie_id |
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 Card | |
def initialize(rank = nil, suit = nil) | |
if suit.nil? | |
@suit = ['♠', '♣', '♥', '♦'].sample | |
else | |
@suit = suit | |
end | |
if rank.nil? | |
srand() | |
@rank = rand(13)+1 |
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 television | |
def initialize(make, model, type, channel = 3, volume = 5) | |
@make = make | |
@model = model | |
@type = type | |
@channel=channel | |
@volume=volume | |
end |
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 Card | |
def initialize(rank, suit) | |
@suit = suit | |
@rank = rank | |
end | |
def suit | |
@suit | |
end | |
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 Car | |
def initialize(color, owner, cylinders) | |
@color = color | |
@owner = owner | |
@cylinders = cylinders | |
end | |
def color | |
@color | |
end |
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 Whiteboard | |
attr_accessor :contents | |
def initialize(contents = []) | |
@contents = contents | |
end | |
def erase | |
@contents = [] | |
end |
OlderNewer