From c870a4ac4101f61b776948a8ab5b3bec52ecf305 Mon Sep 17 00:00:00 2001 From: BillyPittman1993 Date: Tue, 20 Aug 2019 19:55:32 +0000 Subject: [PATCH] Done. --- lib/appointment.rb | 16 ++++++++++++++++ lib/artist.rb | 28 ++++++++++++++++++++++++++++ lib/doctor.rb | 29 +++++++++++++++++++++++++++++ lib/genre.rb | 27 +++++++++++++++++++++++++++ lib/patient.rb | 27 +++++++++++++++++++++++++++ lib/song.rb | 19 +++++++++++++++++++ 6 files changed, 146 insertions(+) diff --git a/lib/appointment.rb b/lib/appointment.rb index e69de29bb2..01c968cc91 100644 --- a/lib/appointment.rb +++ b/lib/appointment.rb @@ -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 \ No newline at end of file diff --git a/lib/artist.rb b/lib/artist.rb index e69de29bb2..4af9f96ca8 100644 --- a/lib/artist.rb +++ b/lib/artist.rb @@ -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 diff --git a/lib/doctor.rb b/lib/doctor.rb index e69de29bb2..eb83710e46 100644 --- a/lib/doctor.rb +++ b/lib/doctor.rb @@ -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 \ No newline at end of file diff --git a/lib/genre.rb b/lib/genre.rb index e69de29bb2..653121522c 100644 --- a/lib/genre.rb +++ b/lib/genre.rb @@ -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 diff --git a/lib/patient.rb b/lib/patient.rb index e69de29bb2..3664e5a237 100644 --- a/lib/patient.rb +++ b/lib/patient.rb @@ -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 diff --git a/lib/song.rb b/lib/song.rb index e69de29bb2..8f64cde3c4 100644 --- a/lib/song.rb +++ b/lib/song.rb @@ -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