Assignment Two CSSE1001 / 7030 Semester 1, 2018 Assignment 2 (20 Marks) Due: Friday 27 April 2018 at 6:00pm Introduction The second assignment is in the same Olympic sports domain as the first...

The question is in the description


Assignment Two CSSE1001 / 7030 Semester 1, 2018 Assignment 2 (20 Marks) Due: Friday 27 April 2018 at 6:00pm Introduction The second assignment is in the same Olympic sports domain as the first assignment. In the second assignment you will be processing the results data from a set of Olympic events. In this assignment you can assume that the data is valid, you just need to process it to determine the results for events. Design You will need to implement several classes for this program. There are two files for the assignment. One is entities.py that contains the class definitions for the data entities in the program. The classes that need to be defined in this file are: • Athlete – data for one athlete competing at the games. • Country – data for one country and it’s delegation at the games. • Event – data for one event at the games. • Result – data that is one athlete’s result in one event. • ManagedDictionary – a wrapper class that provides an application specific interface to a dictionary of items. This is used to create collections that hold all of the athletes, countries and events in the application. These collection objects are defined globally and are to be used by your application and will be queried by the automated marking script. The interfaces for these classes are provided in entities.py and you need to provide the implementations for these classes. Comments are provided to explain what the methods in these classes need to do. Do not change the provided interfaces, as they will be used by the automated marking script. You may add other attributes and methods to these classes as needed for your implementation. There is a function load_data in entities.py that you need to implement to load the data from files. This function needs to load the data into the all_athletes, all_events and all_countries ManagedDictionary objects. The logic for loading data may be lengthy, so you may want to create functions that load a single file and which are called by load_data. As is indicated in the description of the data, implementation of this function can be delayed until after getting other basic functionality working. The other file is processing.py that contains the class definitions for the logical processing of the application. The classes that need to be defined in this file are: • ProcessResults – superclass that defines the logic processing interface. • AthleteResults – provides details of one athlete’s results for all of the events in which they competed. • EventResults – provides details of the results of all athletes who competed in one event. • CountryResults – provides a summary of the results of all athletes who competed for one country. • DeterminePlaces – determines the place ranking of all athletes who competed in one event. The ProcessResults superclass is provided in the processing.py file. The ProcessResults class has two abstract methods. The process method is to be overridden in the subclasses to perform the type of processing of results that are specific to that subclass. It also keeps track of how many times any results processing object executes the process method. The get_results method is to be overridden in the subclasses to return a list of the processed results generated by the process CSSE1001 / 7030 Semester 1, 2018 method. The get_results methods in the subclasses is to raise a ValueError if it is called before the process method has been called. You will need to define and implement the other four classes. They should all inherit from ProcessResults and override its abstract methods. Each of the subclasses that inherit from ProcessResults are to implement a static method called usage_ratio. This method is to return the ratio of how often the specific subclass was used to process results in comparison to all of the other subclasses of ProcessResults. An example is provided of doing this for AthleteResults. AthleteResults is to obtain the results, for one athlete, in all of the events in which they competed. The required processing is to sort these results into best to worst order, based on the place the athlete obtained in each event. If more than one event has the same place, then these should be ordered by the event name, in ascending alphabetical order. The __init__ method needs to take a single parameter which is the Athlete object on whom the processing is to occur. The get_results method is to return a list of Result objects that are ordered according to the logic implemented in the process method. A partial implementation of the AthleteResults class is provided to help clarify the details of what needs to be done in the subclasses. EventResults is to obtain the results of all athletes who competed in the one event. The required processing is to sort these results into best to worst order, based on the places the athletes obtained. If there is a tie and multiple athletes have the same place, then these should be ordered by the athlete’s full name, in ascending alphabetical order. The __init__ method needs to take a single parameter which is the Event object on which the processing is to occur. The get_results method is to return a list of Athlete objects that are ordered according to the logic implemented in the process method. CountryResults is to obtain a summary of the results of one country’s delegation. The required processing is to determine how many gold, silver and bronze medals were won by athletes who competed for the country. It should also be possible to find out how many athletes competed for the country. The __init__ method needs to take a single parameter which is the Country object on which the processing is to occur. The get_results method is to return a list where the first list item is the number of gold medals won by the country, the second is the number of silver medals won, the third is the number of bronze medals won, and the fourth is the number of athletes who competed for the country. The CountryResults class also needs to have methods: get_num_gold, get_num_silver, get_num_bronze and get_num_athletes which return their specific values as ints. DeterminePlaces is to process the results of all athletes who competed in the one event to determine their final places. The required processing is to sort the athlete results into best to worst order, based on the time or score obtained by the athlete. The Event class has an is_timed method that indicates whether the event results are determined by a time value (in seconds) or a score. Timed events are won by the lowest time. Scored events are won by the highest score. Once the results are ordered, the place obtained by each athlete needs to be set in the correct Result object, catering for potential ties in a place. If there is a tie, the place following the tie skips by the number of tied athletes. For example, if there are four athletes, and two tied for second place, there would be athletes who obtained first, second, second and fourth place. The __init__ method needs to take a single parameter which is the Event object on which the processing is to occur. The get_results method is to return a list of Athlete objects that are ordered according to the logic implemented in the process method. If there is a tie and multiple athletes have the same place, then these should be ordered by the athlete’s full name, in ascending alphabetical order. You will need to create one or more functions that implement the main driving logic of your application. You will need to call these in the main block of code, where the demo functions are currently called. CSSE1001 / 7030 Semester 1, 2018 Class Diagram The following diagram provides an overview of the entity and logical processing classes in this design and their relationships. The diagram does not include the ManagedDictionary class. Data The data is stored in five comma-separated values (CSV) files. The athletes.csv file contains data about all the athletes. This file contains four columns: Data Data Type Athlete Identifier Integer Athlete’s First Name String Athlete’s Surname String Country Code String The countries.csv file contains the name and code for each country. Data Data Type Country Code String Country Name String CSSE1001 / 7030 Semester 1, 2018 The events.csv file contains names of the sporting events. Data Data Type Event Name String The timed_event_results.csv file contains data about the results from the sporting events where the results are based on the time taken to complete the event. Data Data Type Athlete Identifier Integer Event Name String Time Result Floating Point The scored_event_results.csv file contains data about the results from the sporting events where the results are based on the score obtained from the judging of the event. Data Data Type Athlete Identifier Integer Event Name String Score Floating Point For the purposes of this assignment the results data files will not contain any results that are DNS, DNF or PEN. Similarly, you can assume that all athletes who compete in an event will obtain a result. You will need to consider the dependencies between the objects in the design to correctly load the data from these five files. When creating an athlete object it needs to know the country for which the athlete is competing. This means you must load the country_codes.csv file before loading the athletes.csv file. But, countries need to know the athletes who belong to their delegation, so you need to add the athlete(s) to their country as you create them. An event also needs to know the athletes who compete in the event. The results files can only be loaded once you have loaded the athletes.csv and events.csv files. Note: To get started on the assignment you can implement your entity and logical processing classes and test these with objects created in the program. (See the demo functions provided in processing.py, which provides an example of doing this.) You can get some the program logic working correctly without loading any data. Once part of your program is working you can then deal with loading the data. User Interaction You may implement a user interface that allows someone to query the program for results. You may find this convenient for visualising what is happening in your program. This
Apr 11, 2020CSSE1001
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here