Question: Python problem!!! A Web site keeps track of downloaded files by using the DownloadInfo and FileDownloads classes. (a) For each download, the site uses a
Python problem!!!
A Web site keeps track of downloaded files by using the DownloadInfo and FileDownloads classes.
(a) For each download, the site uses a DownloadInfo object to store a files name and the number of times it has been downloaded. The DownloadInfo class is constructed from a name of a file (a string). A file is initially downloaded zero times. The class contains the following functionality.
1. get_name for retrieving the files name 2. increment_count, which increments the number of times a file has been downloaded by 1 3. get_count which returns the number of times a file has been downloaded.
Write the DownloadInfo class by writing the appropriate constructor and methods that implement the functionality described above. Name variables appropriately, making use of design techniques.
class DownloadInfo:
(b) A FileDownloads object stores a list of downloaded file information (a list of DownloadInfo) in order to keep track of the downloads of multiple files in an attribute. It has the following functionality:
1. A get_download_info method. It has one parameter, name and returns the DownloadInfo object that matches the parameter name. If no file in the download list has a title matching the parameter, the method should return None.
2. An update_downloads method which takes a list of file names as a parameter (list of string). For each name in the list, the method updates the download list attribute either by incrementing the download count if a DownloadInfo object with the same name exists, or by adding a new DownloadInfo object with that title and a download count of 1 to the end of the list.
For instance, suppose a FileDownloads instance a stores the following downloads, where the table below represents the contents of the download list attribute.
| A movie 5 downloads |
| English Essay 8 downloads |
And then the following is called:
a.update_downloads([Hey Jude, 1984 PDF])
The result is that the FileDownloads instance would now store the following:
| A movie 5 downloads |
| English Essay 8 downloads | 1984 PDF 1 downloads |
Note that it incremented the Hey Jude file download count by 1, and added the 1984 PDF file to the end of the list of downloads.
You must use the get_download_info method in your solution to this method, regardless of it works or not.
write the entire FileDownloads class as it is described in part (b). Include both the appropriate __init__ constructor and the two methods described, get_download_info and update_downloads.
Write the FileDownloads class below.
class FileDownloads:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
