Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement a Javascript class called CovidVaccinationCenter that provides a very simple representation of a COVID vaccination center. When you create an instance of CovidVaccinationCenter, the
Implement a Javascript class called CovidVaccinationCenter that provides a very simple representation of a COVID vaccination center.
When you create an instance of CovidVaccinationCenter, the constructor accepts the following arguments:
- VaccineType: either Pfizer or Moderna
- NumVials: an integer indicating the number of vials of vaccine provided to the vaccination center. For the Pfizer vaccine, each vial contains 5 doses of vaccine. For the Moderna vaccine, each vial contains 10 doses.
- DosesPerDay: an integer indicating the number of doses that the center can administer in a day.
The following methods are defined for the CovidVaccinationCenter class:
- administerDoses(numDoses). Calling this method indicates that numDoses of vaccine have been given and are no longer available.
- remainingDays(). This method returns the number of days before the center runs out of doses if it administers the maximum amount of doses per day. Truncate any partial days.
- receiveShipment(numVials). Calling this method indicates that numVials of vaccine have been received to augment existing supplies. Each center receives shipments only of the initially specified vaccine type.
For example, given the following code:
const queens = new CovidVaccinationCenter("Pfizer", 5000, 500); const kaiser = new CovidVaccinationCenter("Moderna", 3000, 250); console.log(queens.remainingDays()); // prints out 50 (25,000 doses divided by 500 doses/day) console.log(kaiser.remainingDays()); // prints out 120 (30,000 doses divided by 250 doses/day) queens.administerDoses(8000); queens.administerDoses(9000); queens.receiveShipment(1000); console.log(queens.remainingDays()); // prints out 26 kaiser.administerDoses(20000); console.log(kaiser.remainingDays()); // prints out 40
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