Answered step by step
Verified Expert Solution
Link Copied!

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. image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

import java.util.ArrayList; public class Virus { private String family; private String species; private double r0; private ArrayList symptoms; 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 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()); } }
Main (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(ci.getSpecies()); System.out.println(c2.getSpecies()); } > d super 2.3 src Corona Corona.java Main.java Virus.java 2 related problems 1 public class Corona extends Virus 1 2 3 private double mortRate; 4 private int year0fEmergence 5 6 7 8 9 * Default constructor for a Corona. */ 2 related problems public Corona() { super( family: "coronavirus", species: "COVID-62");' mortRate = 0.005; yearOfEmergence = 2002; } 10 11 12 13 14 Corona av Main.java Virujas OL public class Virus { private String family: private String specios; private double ro; private ArrayList symptoms; public Virus() { this family: "", species, O: 1.0, new ArrayList(); } public Virus (String family, String species) this(fantly, species, ro: 1.0, new ArrayList()); } public Virus(string family. String species, double ro) { this(family, species, ro, new ArrayList0); > public Virus(String rondly, string species, ArrayList symptoms) (this(family, species, ro: 1.6, symptoms); } public Virus(String family, String species, double ro, ArrayList symptoms) { this.Tanily - fanily; this species = species; this.r = ro; this.symptoms = symptoms; } public void evolve(double newre, ArrayList newsymptoms) re=newro symptoms - newsymptoms; public ArrayList getsymptoms() { return symptons ; public double getre() { return ro; } public String getFamily) { return family: public void setFanily(String newFamily) { family = newFamily: public String getSpecies() { return species; } public void setSpecies(String newSpecies) { species = newSpecies; >

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

Students also viewed these Databases questions

Question

1. Who will you assemble on the team?

Answered: 1 week ago