python 英文编程代码辅导讲解、辅导 Olympic sports
- 首页 >> Python编程IntroductionThe second assignment is in the same Olympic sports domain as the first assignment. In the secondassignment you will be processing the results data from a set of Olympic events. In this assignmentyou can assume that the data is valid, you just need to process it to determine the results for events.DesignYou 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. Theclasses 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 adictionary of items. This is used to create collections that hold all of the athletes, countriesand events in the application. These collection objects are defined globally and are to beused 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 theimplementations for these classes. Comments are provided to explain what the methods in theseclasses need to do. Do not change the provided interfaces, as they will be used by the automatedmarking script. You may add other attributes and methods to these classes as needed for yourimplementation.There is a function load_data in entities.py that you need to implement to load the data fromfiles. This function needs to load the data into the all_athletes, all_events and all_countriesManagedDictionary objects. The logic for loading data may be lengthy, so you may want to createfunctions that load a single file and which are called by load_data. As is indicated in the descriptionof the data, implementation of this function can be delayed until after getting other basicfunctionality working.The other file is processing.py that contains the class definitions for the logical processing ofthe 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 theycompeted.• 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 onecountry.• 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 classhas two abstract methods. The process method is to be overridden in the subclasses to perform thetype of processing of results that are specific to that subclass. It also keeps track of how many timesany results processing object executes the process method. The get_results method is to beoverridden in the subclasses to return a list of the processed results generated by the processCSSE1001 / 7030 Semester 1, 2018method. The get_results methods in the subclasses is to raise a ValueError if it is called before theprocess method has been called.You will need to define and implement the other four classes. They should all inherit fromProcessResults and override its abstract methods. Each of the subclasses that inherit fromProcessResults are to implement a static method called usage_ratio. This method is to return theratio of how often the specific subclass was used to process results in comparison to all of the othersubclasses 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 theathlete obtained in each event. If more than one event has the same place, then these should beordered by the event name, in ascending alphabetical order. The __init__ method needs to take asingle parameter which is the Athlete object on whom the processing is to occur. The get_resultsmethod is to return a list of Result objects that are ordered according to the logic implemented inthe process method. A partial implementation of the AthleteResults class is provided to help clarifythe 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 requiredprocessing is to sort these results into best to worst order, based on the places the athletesobtained. If there is a tie and multiple athletes have the same place, then these should be orderedby the athlete’s full name, in ascending alphabetical order. The __init__ method needs to take asingle parameter which is the Event object on which the processing is to occur. The get_resultsmethod is to return a list of Athlete objects that are ordered according to the logic implemented inthe process method.CountryResults is to obtain a summary of the results of one country’s delegation. The requiredprocessing is to determine how many gold, silver and bronze medals were won by athletes whocompeted for the country. It should also be possible to find out how many athletes competed forthe country. The __init__ method needs to take a single parameter which is the Country object onwhich the processing is to occur. The get_results method is to return a list where the first list itemis 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 whocompeted 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 todetermine their final places. The required processing is to sort the athlete results into best to worstorder, based on the time or score obtained by the athlete. The Event class has an is_timed methodthat 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 theresults 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 numberof tied athletes. For example, if there are four athletes, and two tied for second place, there wouldbe athletes who obtained first, second, second and fourth place. The __init__ method needs to takea single parameter which is the Event object on which the processing is to occur. The get_resultsmethod is to return a list of Athlete objects that are ordered according to the logic implemented inthe process method. If there is a tie and multiple athletes have the same place, then these shouldbe 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 yourapplication. You will need to call these in the main block of code, where the demo functions arecurrently called.CSSE1001 / 7030 Semester 1, 2018Class DiagramThe following diagram provides an overview of the entity and logical processing classes in this designand their relationships. The diagram does not include the ManagedDictionary class.DataThe data is stored in five comma-separated values (CSV) files. The athletes.csv file contains dataabout all the athletes. This file contains four columns:Data Data TypeAthlete Identifier IntegerAthlete’s First Name StringAthlete’s Surname StringCountry Code StringThe countries.csv file contains the name and code for each country.Data Data TypeCountry Code StringCountry Name StringCSSE1001 / 7030 Semester 1, 2018The events.csv file contains names of the sporting events.Data Data TypeEvent Name StringThe timed_event_results.csv file contains data about the results from the sporting events where theresults are based on the time taken to complete the event.Data Data TypeAthlete Identifier IntegerEvent Name StringTime Result Floating PointThe scored_event_results.csv file contains data about the results from the sporting events wherethe results are based on the score obtained from the judging of the event.Data Data TypeAthlete Identifier IntegerEvent Name StringScore Floating PointFor 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 thedata from these five files. When creating an athlete object it needs to know the country for whichthe athlete is competing. This means you must load the country_codes.csv file before loading theathletes.csv file. But, countries need to know the athletes who belong to their delegation, so youneed to add the athlete(s) to their country as you create them. An event also needs to know theathletes who compete in the event. The results files can only be loaded once you have loaded theathletes.csv and events.csv files.Note: To get started on the assignment you can implement your entity and logical processing classesand test these with objects created in the program. (See the demo functions provided inprocessing.py, which provides an example of doing this.) You can get some the program logicworking correctly without loading any data. Once part of your program is working you can then dealwith loading the data.User InteractionYou may implement a user interface that allows someone to query the program for results. You mayfind this convenient for visualising what is happening in your program. This user interface will notbe assessed or contribute to your marks for the assignment. Your assignment will be marked basedon correct functionality, as determined by the automated tests, and by the quality of yourimplementation.HintsThe focus of this assignment is on demonstrating your ability to implement a simple object-orientedprogram using objects, classes and inheritance. It is possible to pass the assignment if you onlyimplement some of the specified functionality. You should design and implement your program instages, so that after the first stage you will always have a working previous partial implementation.In thinking about the stages to implement the program, consider that some features are easier toimplement than others. Focus on getting the easier features working first. You may find CSSE1001 / 7030 Semester 1, 2018implementing and testing the entity classes easier than the logical processing classes. The logicalprocessing classes are based on the assumption that DeterminePlaces has already processed itsresult.Dealing with athletes who tie for an event and athletes who have the same place result for differentevents is an additional complication to the processing. It is recommended that you get the basicprocessing working, assuming that these complications will not occur. Once the basic processingworks you can then deal with the details of ties and athletes who have the same place in differentevents.SubmissionYou must submit your assignment electronically through Blackboard. You need to submit both yourentities.py and processing.py files (use these names – all lower case). You may submit yourassignment multiple times before the deadline – only the last submission will be marked.Late submission of the assignment will not be accepted. Do not wait until the last minute to submityour assignment, as the time to upload it may make it late. In the event of exceptional personal ormedical circumstances that prevent you from handing in the assignment on time, you may submita request for an extension. See the course profile for details of how to apply for an extension:Requests for extensions must be made no later than 48 hours prior to the submission deadline. Theexpectation is that with less than 48 hours before an assignment is due it should be substantiallycompleted and submittable. Applications for extension, and any supporting documentation (e.g.medical certificate), must be submitted via my.UQ. You must retain the original documentation fora minimum period of six months to provide as verification should you be requested to do so.Assessment and Marking CriteriaThis assignment assesses course learning objectives:1. apply program constructs such as variables, selection, iteration and sub-routines,2. apply basic object-oriented concepts such as classes, instances and methods,3. read and analyse code written by others,4. analyse a problem and design an algorithmic solution to the problem,5. read and analyse a design and be able to translate the design into a working program,6. apply techniques for testing and debuggingCriteria MarkProgramming Constructs• Program is well structured and readable• Identifier names are meaningful and informative• Algorithmic logic is appropriate and uses appropriate constructs• Methods are well-designed, simple cohesive blocks of logic• Object usage demonstrates understanding of differences between classesand instances• Class implementation demonstrates understanding of encapsulation andinheritanceSub-Total 6CSSE1001 / 7030 Semester 1, 2018Functionality• Athlete implemented correctly• Event implemented correctly• Result implemented correctly• Country implemented correctly• AthleteResults implemented correctly• CountryResults implemented correctly• EventResults implemented correctly• DeterminePlaces implemented correctlyDocumentation• All modules, classes, methods and functions have informative docstringcomments• Comments are clear and concise, without excessive or extraneous text• Significant blocks of program logic are clearly explained by commentsYour mark will be limited to a maximum possible value if your program does not execute or crasheswhen executing. Your assignment will be limited to a maximum mark of:• 4, if the program contains syntax or semantic errors that prevent it from executing;• 5, if the program if none of the required functionality is implemented.• 5, if the program crashes when executing using programmatically defined objects;• 6, if the program crashes when executing using the provided data files;• 7, if the program crashes when executing using other test data files;It is your responsibility to ensure that you have adequately tested your program to ensure that it isworking correctly. You are provided with sample data files. These do not cover all possible test cases.Your submitted assignment will be tested with different data files that will contain othercombinations of data that your program should manage. You should create your own data files totest all features of your implementation.In addition to providing a working solution to the assignment problem, the assessment will involvediscussing your code submission with a tutor. This discussion will take place in week 9, in thepractical session to which you have signed up. You must attend that session in order to obtain marksfor the assignment.In preparation for your discussion with a tutor you may wish to consider:• any parts of the assignment that you found particularly difficult, and how you overcamethem to arrive at a solution; or, if you did not overcome the difficulty, what you would liketo ask the tutor about the problem;• whether you considered any alternative ways of implementing a given function;• where you have known errors in your code, their cause and possible solutions (if known).It is also important that you can explain to the tutor the details of, and rationale for, yourimplementation.Marks will be awarded based on a combination of the correctness of your code and on yourunderstanding of the code that you have written. A technically correct solution will not achieve apass mark unless you can demonstrate that you understand its operation.CSSE1001 / 7030 Semester 1, 2018A partial solution will be marked. If your partial solution causes problems in the Python interpreterplease comment out the code causing the issue and we will mark the working code. Python 3.6.4will be used to test your program. If your program works correctly with an earlier version of Pythonbut does not work correctly with Python 3.6.4, you will lose at least all of the marks for thefunctionality criteria.Please read the section in the course profile about plagiarism. Submitted assignments will beelectronically checked for potential plagiarism.