Last active
August 29, 2015 14:05
-
-
Save iamsok/1a5863cc6ada4393ad5a to your computer and use it in GitHub Desktop.
Quick Challenge Card
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
############################################################## | |
#############################CARDS############################ | |
############################################################## | |
class Card | |
def initialize(rank = nil, suit = nil) | |
if suit.nil? | |
@suit = ['♠', '♣', '♥', '♦'].sample | |
else | |
@suit = suit | |
end | |
if rank.nil? | |
@rank = ((2..10).to_a + ['A', 'K', 'Q', 'J']).sample | |
else | |
@rank = rank | |
end | |
puts "Create a new card: #{@rank} of #{@suit}" | |
end | |
end | |
############################################################## | |
#####################TELEVISION############################### | |
############################################################## | |
class Television | |
def initialize(dimensions, brand) | |
@dimensions = dimensions | |
@brand = brand | |
end | |
end | |
class TvShow | |
def initialize(show_time, show_name) | |
@show_time = show_time | |
@show_name = show_name | |
end | |
end | |
class TvChannel | |
def initialize(channel_num, station_name) | |
@channel_num = channel_num | |
@station_name = station_name | |
end | |
end | |
############################################################# | |
####################DAN'S_CAR################################ | |
############################################################# | |
class Car | |
def initialize(color, owner, cylinders) | |
@color = color | |
@owner = owner | |
@cylinders = cylinders | |
end | |
def color | |
@color | |
end | |
def owner | |
@owner | |
end | |
def cylinders | |
@cylinders | |
end | |
end | |
dans_car = Car.new('black', 'Dan', 4) | |
dans_car.color | |
dans_car.owner | |
dans_car.cylinders | |
############################################################# | |
#########################CARDS_GETTERS####################### | |
############################################################# | |
class Card | |
def initialize(rank, suit) | |
@suit = suit | |
@rank = rank | |
end | |
def suit | |
@suit | |
end | |
def rank | |
@rank | |
end | |
end | |
############################################################# | |
########WRITE AN INSTANCE METHOD TO ERASE WHITEBOARD######### | |
############################################################# | |
class Whiteboard | |
attr_accessor :contents | |
def initialize(contents = []) | |
@contents = contents | |
end | |
def clear | |
@contents = [] | |
end | |
end | |
############################################################# | |
###WRITE AN INSTANCE METHOD THAT CHECKS CAPACITY OF MARKER### | |
############################################################# | |
class DryEraseMarker | |
attr_reader :color, :capacity | |
def initialize(color) | |
@color = color | |
@capacity = 100 | |
end | |
INK_USE_PER_CHARACTER = 0.01 | |
def write(contents, whiteboard) | |
@capacity = @capacity - (INK_USE_PER_CHARACTER * contents.length) | |
whiteboard.contents << contents | |
end | |
def ink_remaining | |
if @capacity > 0 | |
true | |
else | |
false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment