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 #1511

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

Done #1511

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
16 changes: 16 additions & 0 deletions lib/appointment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Appointment

attr_accessor :date, :patient, :doctor
@@all = []

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

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

attr_accessor :name

@@all = []

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

def self.all
@@all
end

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

def genres
songs.map {|song| song.genre}
end

def new_song(name, genre)
Song.new(name, self, 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_reader :name

@@all = []

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

def self.all
@@all
end

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

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


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

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

attr_accessor :songs
attr_reader :name

@@all = []

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

def self.all
@@all
end

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

def artists
songs.map {|songs| songs.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, :appointment, :doctor
@@all = []

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

def self.all
@@all
end

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

def doctors
appointments.collect {|appointment| appointment.doctor}
end

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

end
19 changes: 19 additions & 0 deletions lib/song.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Song

attr_accessor :artist, :genre
attr_reader :name

@@all = []

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

def self.all
@@all
end

end