Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

~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

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; } }
  • // question is also as text message
You will apply the concepts you have learned in this law. Your task will be to develoa two new clases (Person and InfoctedPerson, which will interact with the Corana class you scmpleted iron before. Notes: You are not allowed to roodily Vieu, lava. . You will need your complete solution for the Como class from 23 - Where you are we us you judgment or make an assumption. All yow closses reque complete Javedoc document comments Person - Pesostauld have fields for hans, age (Integer). . There should be access and eller meluca lor all the above ciel:. Person hasta constructors: 1. Adelult constructor which initialice the respective lielas to "",0. 2. An overloaded constructor which takes both fields as parameters and initializes accordingly. Infected person - Into tedPero subdeas of Person - Inc.edPerson should have lielus lui: under_iccnd:=, mpton Both AnnaLisL) and diagnosis (oltype Coruncl. Infeedersor should have two constructors 1. A constructor that takes a parameters all the fields specific to Interto Persan exccpt diagnosis. Amaia should always be initialized to mill. 2. A second construcLUI Lie lakes as parameters all the lielu specific lu Inledled Person (excel diagnosis 1,+ name and 200 Hemember your calls toll, there should never be an uninitialized field IntectedPerson noork accessor methods for all its fields. lule.edPersoneesta mulator melde lui underviz-end toe, symptoms. These methods siould like Suing parameters and add the supplied values luthe respective Anlaylisl. YOU MUST Chek for duplicates before adding InfocedPerson has a method called :: Sy... This mathad takes a Corona objart as a parameter. An Incotex Porsan is said to be symptomatic if they have at least 75% of the symptoms from the Corna abjctsfiol. If the IncedPerson dors have at least 75% of the synplomms the diagnosis set to the Corura object, and a boolean c. is returried. Otherwise, just relui S

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

Ai And The Lottery Defying Odds With Intelligent Prediction

Authors: Gary Covella Ph D

1st Edition

B0CND1ZB98, 979-8223302568

More Books

Students also viewed these Databases questions