Skip to main content
Bumped by Community user
added 3 characters in body; edited title
Source Link
mdfst13
  • 21.7k
  • 6
  • 33
  • 68

Simple object oriented design for aan Allergy class.

1.Build a system for entering and displaying the allergies that patients may have. 2. The allergy will have its own set of symptoms reactions. The allergy will also have a spectrum of severity which the clinician should be aware of, and allergies can be reported by the patient or by next of kin.

  1. Build a system for entering and displaying the allergies that patients may have.
    2. The allergy will have its own set of symptoms reactions. The allergy will also have a spectrum of severity which the clinician should be aware of, and allergies can be reported by the patient or by next of kin.

Please review my code and tell me how can I can improve my object-oriented design.

class Allergy 
    
    attr_accessor :name, :reporter, :time_reported
    attr_reader :symptoms
    
    def initialize(name, reporter, time_reported=Time.now)
        @name = name
        @reporter = reporter
        @symptoms = []
        @time_reported = time_reported
    end

    
    def add_symptoms(symptom, severity)
        symptom = Symptom.new(symptom, severity)
        @symptoms.push(symptom)
    end
    
    
end

class Symptom
    attr_accessor :symptom, :severity
    
    def initialize(symptom, severity)
        @symptom = symptom
        @severity = severity
    end
    
end

Simple object oriented design for a Allergy class.

1.Build a system for entering and displaying the allergies that patients may have. 2. The allergy will have its own set of symptoms reactions. The allergy will also have a spectrum of severity which the clinician should be aware of, and allergies can be reported by the patient or by next of kin.

Please review my code and tell me how can I improve my object-oriented design.

class Allergy 
    
    attr_accessor :name, :reporter, :time_reported
    attr_reader :symptoms
    
    def initialize(name, reporter, time_reported=Time.now)
        @name = name
        @reporter = reporter
        @symptoms = []
        @time_reported = time_reported
    end

    
    def add_symptoms(symptom, severity)
        symptom = Symptom.new(symptom, severity)
        @symptoms.push(symptom)
    end
    
    
end

class Symptom
    attr_accessor :symptom, :severity
    
    def initialize(symptom, severity)
        @symptom = symptom
        @severity = severity
    end
    
end

Simple object oriented design for an Allergy class

  1. Build a system for entering and displaying the allergies that patients may have.
    2. The allergy will have its own set of symptoms reactions. The allergy will also have a spectrum of severity which the clinician should be aware of, and allergies can be reported by the patient or by next of kin.

Please review my code and tell me how I can improve my object-oriented design.

class Allergy 
    
    attr_accessor :name, :reporter, :time_reported
    attr_reader :symptoms
    
    def initialize(name, reporter, time_reported=Time.now)
        @name = name
        @reporter = reporter
        @symptoms = []
        @time_reported = time_reported
    end

    
    def add_symptoms(symptom, severity)
        symptom = Symptom.new(symptom, severity)
        @symptoms.push(symptom)
    end
    
    
end

class Symptom
    attr_accessor :symptom, :severity
    
    def initialize(symptom, severity)
        @symptom = symptom
        @severity = severity
    end
    
end
Source Link

Simple object oriented design for a Allergy class.

1.Build a system for entering and displaying the allergies that patients may have. 2. The allergy will have its own set of symptoms reactions. The allergy will also have a spectrum of severity which the clinician should be aware of, and allergies can be reported by the patient or by next of kin.

Please review my code and tell me how can I improve my object-oriented design.

class Allergy 
    
    attr_accessor :name, :reporter, :time_reported
    attr_reader :symptoms
    
    def initialize(name, reporter, time_reported=Time.now)
        @name = name
        @reporter = reporter
        @symptoms = []
        @time_reported = time_reported
    end

    
    def add_symptoms(symptom, severity)
        symptom = Symptom.new(symptom, severity)
        @symptoms.push(symptom)
    end
    
    
end

class Symptom
    attr_accessor :symptom, :severity
    
    def initialize(symptom, severity)
        @symptom = symptom
        @severity = severity
    end
    
end