From d329c46ae4e058f6c39cf1a691623e3a23cbba24 Mon Sep 17 00:00:00 2001 From: andy-aguilar Date: Wed, 25 Nov 2020 10:28:12 -0600 Subject: [PATCH] Done. --- lib/appointment.rb | 16 ++++++++++++++++ lib/artist.rb | 26 ++++++++++++++++++++++++++ lib/doctor.rb | 27 +++++++++++++++++++++++++++ lib/genre.rb | 22 ++++++++++++++++++++++ lib/patient.rb | 26 ++++++++++++++++++++++++++ lib/song.rb | 18 ++++++++++++++++++ 6 files changed, 135 insertions(+) diff --git a/lib/appointment.rb b/lib/appointment.rb index e69de29bb2..654f3850b3 100644 --- a/lib/appointment.rb +++ b/lib/appointment.rb @@ -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 \ No newline at end of file diff --git a/lib/artist.rb b/lib/artist.rb index e69de29bb2..8df4fb3481 100644 --- a/lib/artist.rb +++ b/lib/artist.rb @@ -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 \ No newline at end of file diff --git a/lib/doctor.rb b/lib/doctor.rb index e69de29bb2..7d46610380 100644 --- a/lib/doctor.rb +++ b/lib/doctor.rb @@ -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 \ No newline at end of file diff --git a/lib/genre.rb b/lib/genre.rb index e69de29bb2..8a28a6d6e5 100644 --- a/lib/genre.rb +++ b/lib/genre.rb @@ -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 \ No newline at end of file diff --git a/lib/patient.rb b/lib/patient.rb index e69de29bb2..c90fca3400 100644 --- a/lib/patient.rb +++ b/lib/patient.rb @@ -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 \ No newline at end of file diff --git a/lib/song.rb b/lib/song.rb index e69de29bb2..b1fd36474f 100644 --- a/lib/song.rb +++ b/lib/song.rb @@ -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 \ No newline at end of file