Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #1507

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #1507

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/appointment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Appointment

attr_accessor :date, :patient, :doctor

@@all = []

def initialize(date, patient, doctor)
@date = date
@patient = patient
@doctor = doctor
@@all << self
end

def self.all
@@all
end


end
27 changes: 27 additions & 0 deletions lib/artist.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class Artist

attr_accessor :name

@@all = []

def self.all
@@all
end

def initialize(name)
@name = name
@@all << self
end

def new_song(song, genre)
Song.new(song, self, genre)
end

def songs
Song.all.select {|song| song.artist == self}
end

def genres
songs.collect {|song| song.genre}
end
end
29 changes: 29 additions & 0 deletions lib/doctor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Doctor
attr_accessor :name

@@all = []

def self.all
@@all
end

def initialize(name)
@name = name
@@all << self
end

def new_appointment(patient, date)
Appointment.new(date, patient, self)

end

def appointments
Appointment.all.select {|appointment| appointment.doctor == self}
end

def patients
appointments.collect {|appointment| appointment.patient}
end


end
26 changes: 26 additions & 0 deletions lib/genre.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Genre
attr_accessor :name

@@all = []

def self.all
@@all
end

def initialize(name)
@name = name
@@all << self
end

def new_song(song, artist)
Song.new(song, artist, self)
end

def songs
Song.all.select {|song| song.genre == self}
end

def artists
songs.collect {|song| song.artist}
end
end
27 changes: 27 additions & 0 deletions lib/patient.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class Patient

attr_accessor :name

@@all = []

def self.all
@@all
end

def initialize(name)
@name = name
@@all << self
end

def new_appointment(doctor, date)
Appointment.new(date, self, doctor)
end

def appointments
Appointment.all.select {|appointment| appointment.patient == self}
end

def doctors
appointments.collect {|appointment| appointment.doctor}
end
end
18 changes: 18 additions & 0 deletions lib/song.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Song

attr_accessor :name, :artist, :genre

@@all = []

def self.all
@@all
end

def initialize(name, artist, genre)
@name = name
@artist = artist
@genre = genre
@@all << self
end

end