Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please do Task 2.3 in java. import java.util.ArrayList; public class Virus { private String family; private String species; private double r0; private ArrayList symptoms; public
please do Task 2.3 in java.
import java.util.ArrayList; public class Virus { private String family; private String species; private double r0; private ArrayListsymptoms; public Virus() { this("", "", 1.0, new ArrayList ()); } public Virus(String family, String species) { this(family, species, 1.0, new ArrayList ()); } public Virus(String family, String species, double r0) { this(family, species, r0, new ArrayList ()); } public Virus(String family, String species, ArrayList symptoms) { this(family, species, 1.0, symptoms); } public Virus(String family, String species, double r0, ArrayList symptoms) { this.family = family; this.species = species; this.r0 = r0; this.symptoms = symptoms; } public void evolve(double newR0, ArrayList newSymptoms) { r0 = newR0; symptoms = newSymptoms; } public ArrayList getSymptoms() { return symptoms; } public double getR0() { return r0; } public String getFamily() { return family; } public void setFamily(String newFamily) { family = newFamily; } public String getSpecies() { return species; } public void setSpecies(String newSpecies) { species = newSpecies; } }
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; } }
import java.util.ArrayList; import java.util.Arrays; public class Main { public static void main(String[] args) { // fix this! Corona c1 = new Corona( 0.007, 2019, 1.5, new ArrayListMain (3) Description this and super are a couple of handy reserved words in Java. We have already seen this used fairly extensively, but have never discussed it. Conceptually they are simple to understand, and that is what we will be doing in this section ~Task 2.3 There is some code written in Main.java . In Corona.java , modify and add everything needed to make the errors in main() disappear. Do not change the code in main() or Virus.java. The output should also correctly validate upon checking your answer. Hint A Corona object's family is always "coronavirus"; a Corona object's species is always the concatenation of "COVID-" and the last two digits of the yearofEmergence. Make use of super and this where required and in places they may be useful (for example: constructor chaining). You only need to define as many consthistors as are necessary to remove the errors, you can keep the default constructor. If you choose to define any methods in Corona.java, they must be private. Check your answer. Check 5 7 minutornan orona.java Main.java Virus.java simport java.util.ArrayList; import java.util.Arrays; public class Maint public static void main(String[] args) { // fix this! Corona ci = new Corona 0.00 2819 new ArrayList(Arrays.asList("sniffles", "fever", "cough", "shortness of breath")) ); Corona c2 = new Corona( 0.3, 2014, new ArrayList (Arrays.asList("fever", "cough", "shortness of breath")) ); // for validation System.out.println(c1.getSpecies()); System.out.println(c2.getSpecies()); } }
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