diff --git a/lib/appointment.rb b/lib/appointment.rb index e69de29bb2..f24404e566 100644 --- a/lib/appointment.rb +++ b/lib/appointment.rb @@ -0,0 +1,17 @@ +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 diff --git a/lib/artist.rb b/lib/artist.rb index e69de29bb2..dce8ae0669 100644 --- a/lib/artist.rb +++ b/lib/artist.rb @@ -0,0 +1,33 @@ +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 new_song(name, genre) + song = Song.new(name, self, genre) + end + + def genres + artist_genres = [] + Song.all.each do |song| + if song.artist == self + artist_genres << song.genre + end + end + artist_genres + end +end diff --git a/lib/doctor.rb b/lib/doctor.rb index e69de29bb2..a7107b9683 100644 --- a/lib/doctor.rb +++ b/lib/doctor.rb @@ -0,0 +1,32 @@ +class Doctor + @@all = [] + attr_accessor :name + + def initialize(name) + @name = name + @@all << self + end + + def self.all + @@all + end + + def appointments + Appointment.all.select{|appointment| appointment.doctor == self} + end + + def new_appointment(date, patient) + Appointment.new(date, patient, self) + end + + def patients + doctor_patients = [] + Appointment.all.each do |appointment| + if appointment.doctor == self + doctor_patients << appointment.patient + end + end + doctor_patients + end + +end diff --git a/lib/genre.rb b/lib/genre.rb index e69de29bb2..18101281a2 100644 --- a/lib/genre.rb +++ b/lib/genre.rb @@ -0,0 +1,28 @@ +class Genre + @@all = [] + attr_accessor :name + + 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 + genre_artists = [] + Song.all.each do |song| + if song.genre == self + genre_artists << song.artist + end + end + genre_artists + end + +end diff --git a/lib/patient.rb b/lib/patient.rb index e69de29bb2..e412515eea 100644 --- a/lib/patient.rb +++ b/lib/patient.rb @@ -0,0 +1,31 @@ +class Patient + @@all = [] + attr_accessor :name + + def initialize(name) + @name = name + @@all << self + end + + def self.all + @@all + end + + def new_appointment(date, doctor) + Appointment.new(date, self, doctor) + end + + def appointments + Appointment.all.select{|appointment| appointment.patient == self} + end + + def doctors + patient_doctors = [] + Appointment.all.each do |appointment| + if appointment.patient == self + patient_doctors << appointment.doctor + end + end + patient_doctors + end +end diff --git a/lib/song.rb b/lib/song.rb index e69de29bb2..aae58c1d6b 100644 --- a/lib/song.rb +++ b/lib/song.rb @@ -0,0 +1,15 @@ +class Song + @@all = [] + attr_accessor :name, :artist, :genre + + def initialize(name, artist, genre) + @name = name + @artist = artist + @genre = genre + @@all << self + end + + def self.all + @@all + end +end