Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in java please Notes: You are not allowed to modify Virus.java . You will need your completed solution for the Corona class from 2.3. Where
in java please
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:
- A default constructor which initializes the respective fields to "", 0.
- 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:
- A constructor that takes as parameters all the fields specific to InfectedPerson except diagnosis. diagnosis should always be initialized to null.
- A second constructor that takes as parameters all the fields specific to InfectedPerson (except diagnosis), + name and age.
- 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; 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; } public Corona(double mortRate, int yearOfEmergence, ArrayList symptoms) { super("coronavirus", "COVID-" + String.valueOf(yearOfEmergence % 100), symptoms); this.mortRate = mortRate; this.yearOfEmergence = yearOfEmergence; } 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; } }
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; } }Problem 4.1 You will apply the concepts you have learned in this tab. Your tank will be to develop two new classes (Person and intoctoderson), which wie interact with the Corona class you completed from belore Notes: . You are not allowed to modly 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 initialize the respective fields to 2. An overloaded constructor which takes both holds as parameters and initializes accordingly InfectedPerson: InfectedPerson is a subclass of Person InfectedPerson should have fields for underlying Conditions, symptoms (both ArrayLists), and diagnosis (of type Corona). InfectedPerson should have two constructors: 1. A constructor that takes as parameters all the folds spocific 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 underlying Conditions, 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started