Question: THIS IS A JAVA Q ABOUT INHERITENCE AND SUPER CLASSES Make use of super and this where required and in places they may be useful

THIS IS A JAVA Q ABOUT INHERITENCE AND SUPER CLASSES

THIS IS A JAVA Q ABOUT INHERITENCE AND SUPER CLASSES Make use

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 constructors 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.

/* MAIN */ 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()); } }

/*Virus*/

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; } } 

/*CORONA*/

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; } } 

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!