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

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

Done #1530

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
17 changes: 17 additions & 0 deletions lib/appointment.rb
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions lib/artist.rb
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions lib/doctor.rb
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions lib/genre.rb
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions lib/patient.rb
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions lib/song.rb
Original file line number Diff line number Diff line change
@@ -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