Question: 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

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!