Question: Implement the class Vaccine so that it contains: 3 private instance variables: name of type String, doses of type integer which records the number




Implement the class Vaccine so that it contains: 3 private instance variables:name of type String, doses of type integer which records the number

Implement the class Vaccine so that it contains: 3 private instance variables: name of type String, doses of type integer which records the number of doses taken, and isAuthorized which is Boolean and indicates if the vaccine is proven safe or not. A default constructor which sets the numeric instance variable to zero and the String instance variable to null. A constructor with 3 parameters which sets the 3 instance variables to the corresponding values passed. Implement an accessor method for each of the 3 instance variables that will return the value of the instance variable. For example, the getX() method for the instance variable name must be called getName(). Implement a mutator method for each instance variable that will assign to the instance variable the value passed. For example, the setX() method for the instance variable type must be called setName(). An equals method: two objects of type Vaccine are equal if all the attributes of both objects have the same values. A Boolean method bothAuthorized which returns true if both vaccines are Authorized and false otherwise. A toString function must also be provided to return the vaccine information in the following format: The Vaccine of name has dose(s) and is Authorized is Where , and are the contents of the instance variables. If you correctly implemented all the above, running the main method will result in your program displaying exactly as in the boxes below. Your program should work for any values entered. REMEMBER in the output: is a space, is a tab and J is a new line. Text in green is user input. The only formatting you are concerned with is the one generated by the toString method (in blue) the rest is already set in the main method which you are not to change. What is the name of this Vaccine? Polio How many needed doses of this Vaccine?4 Is it an Authorized Vaccine? (true or false) true The two Vaccines are: The Vaccine of name null has 0dose(s) and is Authorized is false The Vaccine of name Polio has 4dose(s) and is Authorized is true Let's set up the 1st Vaccine... What is the name? Polio How many doses?4 Is it an Authorized Vaccine (true or false)? false Vaccine 1: The Vaccine of name Polio has 4 dose(s) and is Authorized is false Are the 2 Vaccine objects equal? No Are they both Authorized Vaccine? false Now are they both Authorized Vaccine? true What is the name of this Vaccine? Cholera How many needed doses of this Vaccine?1 Is it an Authorized Vaccine? (true or false) ofalse The two Vaccines are: The Vaccine of name null has 0dose(s) and is Authorized is false The Vaccine of name Cholera has 1 dose(s) and is Authorized is false Let's set up the 1st Vaccine... What is the name? Polio How many doses?4 Is it an Authorized Vaccine (true or false)? false Vaccine 1: The Vaccine of name Polio has 4 dose(s) and is Authorized is false Are the 2Vaccine objects equal? No Are they both Authorized Vaccine? false Now are they both Authorized Vaccine? false Note 1: You are to expect a perfect user who will always enter valid values; that is, do not verify the validity of user input. Note 2: The use of libraries other than java.util.Scanner is prohibited. Your program must work for data entered, not just the ones in the samples above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is an example implementation of the Vaccine class in Java java public class Vaccine private String name private int doses private boolean isAutho... View full answer

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 Programming Questions!