Question: Part 2 Make a Class called Virus that has these instance variables: String name int yearDiscovered double rFactor boolean vaccineAvail Make 3 constructors - complete(4
Part 2
Make a Class called Virus that has these instance variables:
String name
int yearDiscovered
double rFactor
boolean vaccineAvail
Make 3 constructors - complete(4 parameters), default(no parameters) , Copy( 1 parameter)
Make a setters and getters for each variable.
Make a toString that returns the variables formatted like this
Name:COVID-19
Year :2019
Rfactor: 1.3
Vaccine Available.
To get the last line you will need a if statement in the toString method - based on the result you will append Vaccine Available or Vaccine not Available to the toString
Make an equals method that returns a boolean. It should have 1 parameter which is an object of the class type. In the method you compare the instance variables name and yearDiscovered
Write a driver to test all the parts- meaning use all 3 constructors, setters, getters, toString. Check the equals in the true case and the false case
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
