Created
July 7, 2017 00:00
-
-
Save oddlyfunctional/1bbd0cb57506276ae2b1d8d73b60214a to your computer and use it in GitHub Desktop.
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 Restaurant | |
attr_reader :name | |
attr_accessor :tables | |
def initialize(name, tables, style) | |
@name = name | |
@tables = tables | |
@style = style | |
@clients = [] | |
end | |
def open? | |
if Time.now.hour >= 12 && Time.now.hour <= 16 | |
return true | |
else | |
return false | |
end | |
end | |
def book(client) | |
@clients << client | |
end | |
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
require_relative "restaurant" | |
la_mama = Restaurant.new("La Mama", 10, "italiano") | |
umai = Restaurant.new("Umai", 20, "japonês") | |
puts "#{la_mama.name} tem #{la_mama.tables} lugares" | |
puts "#{umai.name} tem #{umai.tables} lugares" | |
umai.tables = 30 | |
puts "#{umai.name} tem #{umai.tables} lugares" | |
puts "O #{umai.name} está #{umai.open? ? "aberto" : "fechado"}" | |
p umai | |
umai.book("Marcos") | |
umai.book("Joaquim") | |
p umai |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment