Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with java ( Also provided Transcribed image text) if image is not clear. ~Problem 4.1~ You will apply the concepts you have learned

Please help with java ( Also provided Transcribed image text) if image is not clear.

image text in transcribed

~Problem 4.1~

You will apply the concepts you have learned in this lab. Your task will be to develop two new classes (Person and InfectedPerson), which will interact with the Corona class you completed from before.

Notes:

  • You are not allowed to modify Virus.java.
  • You will need your completed solution for the Corona class from 2.3.
  • Where you are unsure, use your judgment or make an assumption.
  • All your classes require complete Javadoc document comments.

Person:

  • Person should have fields for: name, age (Integer).
  • There should be accessor and setter methods for all the above fields.
  • Person has two constructors:
    1. A default constructor which initializes the respective fields to "", 0.
    2. An overloaded constructor which takes both fields as parameters and initializes accordingly.

InfectedPerson:

  • InfectedPerson is a subclass of Person.
  • InfectedPerson should have fields for: underlyingConditions, symptoms (both ArrayLists), and diagnosis (of type Corona).
  • InfectedPerson should have two constructors:
    1. A constructor that takes as parameters all the fields specific to InfectedPerson except diagnosis. diagnosis should always be initialized to null.
    2. A second constructor that takes as parameters all the fields specific to InfectedPerson (except diagnosis), + name and age.
    Remember your calls to super(), there should never be an uninitialized field!
  • InfectedPerson needs accessor methods for all its fields.
  • InfectedPerson needs mutator methods for underlyingConditions, symptoms. These methods should take String parameters and add the supplied values to the respective ArrayList. You MUST check for duplicates before adding!
  • InfectedPerson has a method called isSymptomatic(). This method takes a Corona object as a parameter. An InfectedPerson is said to be symptomatic if they have at least 75% of the symptoms from the Corona object's symptoms field. If the InfectedPerson does have at least 75% of the symptoms the diagnosis is set to the Corona object, and a boolean true is returned. Otherwise, just return false.

  • ---------------------------------------------------
    import java.util.ArrayList; /** * A Virus. */ public class Virus { private String family; private String species; private double r0; private ArrayList symptoms; /** * Default constructor. */ public Virus() { this("", "", 1.0, new ArrayList()); } /** * Constructor for a Virus. * * @param family String, the family * @param species String, the species */ public Virus(String family, String species) { this(family, species, 1.0, new ArrayList()); } /** * Constructor for a Virus. * * @param family String, the family * @param species String, the species * @param r0 double, the r0 rate */ public Virus(String family, String species, double r0) { this(family, species, r0, new ArrayList()); } /** * Constructor for a Virus. * * @param family String, the family * @param species String, the species * @param symptoms ArrayList, list of symptoms */ public Virus(String family, String species, ArrayList symptoms) { this(family, species, 1.0, symptoms); } /** * Constructor for a Virus. * * @param family String, the family * @param species String, the species * @param r0 double, the r0 rate * @param symptoms ArrayList, list of symptoms */ public Virus(String family, String species, double r0, ArrayList symptoms) { this.family = family; this.species = species; this.r0 = r0; this.symptoms = symptoms; } /** * Update characteristics of the Virus. * * @param newR0 double, the new r0 value * @param newSymptoms ArrayList, new list of symptoms */ public void evolve(double newR0, ArrayList newSymptoms) { r0 = newR0; symptoms = newSymptoms; } /** * Get Virus symptoms. * * @return String, list of symptoms */ public ArrayList getSymptoms() { return symptoms; } /** * Get Virus r0. * * @return double, the r0 value */ public double getR0() { return r0; } /** * Get Virus family. * * @return String, the family */ public String getFamily() { return family; } /** * Set Virus family. * * @param newFamily String, new family */ public void setFamily(String newFamily) { family = newFamily; } /** * Get Virus species. * * @return String, the species */ public String getSpecies() { return species; } /** * Set Virus species. * * @param newSpecies String, new species */ public void setSpecies(String newSpecies) { species = newSpecies; } } 
  • -------------------------------------------------------------------------------------- public class Main { public static void main(String[] args) { // the floor is yours } }
  • -------------------------------------------------------------------------------------- import java.util.ArrayList; public class Corona extends Virus { private double mortRate; private int yearOfEmergence; /** * Default constructor for a Corona. */ public Corona() { super("coronavirus", "COVID-02"); mortRate = 0.005; yearOfEmergence = 2002; } // constructors to fix error in main public Corona(double mortRate, int yearOfEmergence, ArrayList symptoms) { super("coronavirus", "COVID-" + String.valueOf(yearOfEmergence % 100), symptoms); this.mortRate = mortRate; this.yearOfEmergence = yearOfEmergence; } // constructor to fix error in main public Corona(double mortRate, int yearOfEmergence, double r0, ArrayList symptoms) { super("coronavirus", "COVID-" + String.valueOf(yearOfEmergence % 100), r0, symptoms); this.mortRate = mortRate; this.yearOfEmergence = yearOfEmergence; } }
-Problem 4.1- You will apply the concepts you have learned in this lab. Your task will be cu develop worew classes Person and InfectedPerson), which will interact with the Curera clase you completed Irwirbelbre. Notes You are at allowed to madify Vi-... - You will rece your completed solution for the Corona cioss lom 2.3. - Where you are answe use you judgment or make on assumption. All your classes require complece lavadar document comments Person Person should have fields for us, age Integer There should be acrector and setter methods for all the above falck - Person has the constructors: 1. A default constructor which initalizes the respective fields to ".C. 2. An overloaded constructor which takes both fields as caracters and initiaizes accordingly. Infected Person: llecedPerson is a subclass of Person. Info todlerson should have fields for rularly, yunthotherapists, and :i-mi jof type Corona - IntecedPerson should have two constructors: 1. A constructor that takes as parameters all the fields specfic to InfectedPerson except divis. diuosi, should always be initalized to cull. 2. Accord constructor that takes as parameters all the folk sporific to InfectedPerson rxcept : ii : ) + HAN. Revyber your calls to all, there well ever to or viticize licc! InfectedPerson needs accessor methods for all its felels. InfostedPersonncoris mutator methoek torlin, yks. These methods should take String parameters and and the suplid values to the respective. Altaylist. YOU MUST Crucklor duplicies belure ciling! lufected person has a method called in Longlii . This method takes a Corona object as a parameter. An Infected person is said to be symptomatic if they have at least 75% of the symptoms from the Corona object's simples fielel. If the infected person does have at least 25% of the symtoms the l' is set to the corona chject, and a hoolean His returned Otherwise, just ratum

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Generative Artificial Intelligence For Project Management With Aws

Authors: Timothy Krimmel

1st Edition

B0CQV9KWB8, 979-8872627197

More Books

Students also viewed these Databases questions

Question

=+ 8-5 Describe inferential statistics.

Answered: 1 week ago