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

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

Done #1525

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(date, patient, doctor)
@date = date
@patient = patient
@doctor = doctor
@@all << self
end

def self.all
@@all
end
end
26 changes: 26 additions & 0 deletions lib/artist.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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.new(name, self, genre)
end

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

@@all = []

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

def self.all
@@all
end

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

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

def patients
self.appointments.map{|a| a.patient}
end
end
22 changes: 22 additions & 0 deletions lib/genre.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Genre
attr_accessor :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
self.songs.map{|song| song.artist}.uniq
end
end
26 changes: 26 additions & 0 deletions lib/patient.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Patient
attr_accessor :name

@@all = []

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

def self.all
@@all
end

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

def doctors
self.appointments.map{|a| a.doctor}
end

def new_appointment(date, doctor)
Appointment.new(date, self, 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 :title, :genre, :artist

@@all = []

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

def self.all
@@all
end


end