You are tasked to write a program which will handle information related to the outbreak of coronavirus. The main goal is to facilitate representation, correction, adding and manipulation of data regarding the spread of the virus. We will base this on a file from the website ourworldindata.org.

The file contains information about detected infection with the covid-19 disease in many countries. Each line in the file has information about country, date and confirmed cases in the given country at this date. Here are some examples of lines from Singapore:

Singapore,SIN,"Apr 7, 2020",5755,31
Singapore,SIN,"Apr 8, 2020",5863,32
Singapore,SIN,"Apr 9, 2020",6010,33

The last number on the line is not used in this exercise. The number after the date is the accumulated number of cases for Singapore in the days 7th, 8th and 9th of April 2020. You can assume that all lines are given on this format, and always consists of exactly 5 commas.

We can see that country, date and infected are central concepts in the data.

The program that you are tasked to write will read this data and add them into a data structure so that it is possible to make subroutines which represent, correct, add and extract parts of the information.

The program should consist of the classes Country, Date and Infection for the central concepts in the data. In addition, you will write the class Region. Instances of this class can contain infection data for a subset of countries as the sum of the infected in each country. The class Date should have the instance variables year, month and day. It is a requirement that for a single date, there should only be one object (instance) in the data structure. This means that all registrations of infection has a variable for date, referring to the same object. Objects for e.g. the 1st of April, has variables with the values year = 2020, month = 4 and day =1. The data type for these instance variables must be given as integers.

The class Infection contains information about the infection status at a given date for a given country. The infection status is the number of people who have tested positive for covid-19 in this country on this given date. The class should have instance variables for the number of infected, the number of tested persons, the number of hospitalized persons, the number of people in the ICU requiring treatment in a respirator, as well as the number of dead from covid-19 for the given country at the given date. It is a requirement that there is no instance variable for Country in the class Infection. The information about which country these registrations come from, will be handled by the Country objects which contain the actual registrations.

In addition to the classes Country, Date and Infection, you are tasked to write a main program, called main, where the user first will be asked to give the name of the file with t he infection data. By using a menu loop and input, the user will be able to give a character to test that the program works as intended:

c -(country) writes infection data for the country given by user input
d (date) writes infection data for all countries at a date given by the user
g (group) creates a region with infection data for a group of countries
m (max) finds which date the infection spread the most in a given region
n (new) adds new information to the data structure
p (plot) plots graphs for countries (one or more) given by the user. This is NOT mandatory, but if you choose to do it you will need the library matplotlib.
q (quit) makes the program leave the menu loop and terminates the program
r (remove) removes all objects of Infection with a number of infected equal to 0, which comes earlier than the first day of detected spread
w (write) writes the data structure to a file, such as this file can be used as the input file to your program

You do not have to program all of these functions.

The program should have a global structure consisting of at least one dictionary. Apart from the requirements above, you are free to add your own classes, functions, procedures, global and instance variables and methods. Use informative names and comment thoroughly what you intend to use them for.

When a new region (instance of Region) is created, a name and code for this region will have to be input by the user, together with information about which countries should be added to this region.

Task 1

Write the main procedure which reads the file, creates the data structure with countries, dates and corresponding numbers of infected people. The main procedure then starts the menu loop.

For each choice in the menu, a separate subroutine which, apart from where you are expected to write code, does nothing.

Task 2

Write the class Date

Task 3

Write the class Country

Task 4

Write the class Infection

Task 5

Write the subroutine corresponding to the menu option 'd'

Task 6

Write the subroutine corresponding to the menu option 'r'

Task 7

Write the class Region. It should have the same instance variables as Country. The constructor in Region must have parameters, which is the input the user has given on the terminal for the new region.

I.e. three parameters as given:

  • The name of the region
  • The code for the region
  • A list of countries which are related to this region

The constructor will also calculate the infection data for the new region, as the sum of the infection data for the countries included in the region.

Task8

Write the subroutine corresponding to the menu option 'm'

Task 9

Write the subroutine corresponding to the menu option 'w'

You are free to solve the tasks in the order of your choosing. Each individual task shall be written as a single Python file.

Task 10 Report

The system you are tasked to build in the practical part of this exam addresses real data related to the outbreak of coronavirus. In the program you are tasked to write a class Date with the instance variables year, month and date. This information could easily have been represented by a single string, yet you are tasked to write a separate class which can be used to build objects.

Discuss the advantages and disadvantages of representing a date as a class, rather than a simple string, in the practical part of this exam. Your submission should quote relevant concepts from the curriculum.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.