Answered step by step
Verified Expert Solution
Question
1 Approved Answer
need help with this C++ program comments are especially useful Olympic Lab be rewritten in object-oriented style. You have been selected for the joh Fortunately
need help with this C++ program comments are especially useful
Olympic Lab be rewritten in object-oriented style. You have been selected for the joh Fortunately (or perhaps not), some of the preliminary design work has e In ternational Olympic Committee needs your help. The co who won races based on the timing data from each lanprogram that figures out done, and the main program that inputs the data and prints it out has alread been written. Your job is to write two C++ classes, Competitor and R both declaration (h) and implementation (.cpp), to store information competitor in a race and to rank these competitors from lowest to highest finishing time. This code should be divided into four files: competitor.h competitor.cpp, ranker.h, and ranker.cpp Objects of the Competitor class are initialized with the person's name and lane assignment, specified as a character string and an integer. The person's name should be copied into the Competitor object's own memory; that is, don't just record the pointer that was passed in. Note that there should be no predefined size for the person's name. Also note that you should not use any C++ predefined String class for this lab. Since the person's time is not known at the outset, this value is set with a separate member function called setrime () which accepts a double floating-point value. There should also be member functions to retrieve the name, lane, and time, as well as a member function to print out the object as a single line of text. Finishing times should be output to one decimal place. Finally, don't forget to have the class destructor deallocate any storage when an object of this class goes out of scope Objects of the Ranker class are initialized with the number of items Competitor objects) to be ranked. Pointers to competitor objects are passed to an addlist() member function one by one. If a NULL pointer passed in, or if the total number of objects passed in exceeds the pre-define number of items, addList ) should number of competitor objects passed in. Items are from the list using two member functi accepts an integer from 1 to the number o return 0; otherwise, it returns the total getLane() and getFinish) retrieved (but not remov to the Competitor object in the specified lane, while get pointer to the competitor who finished at the specified f items in the list. geti Each returns a second, etc.). Finaly, when a Ranker object is destroyed, it frees ) returnsa t allocated for itseltf, but it does not delete the memory for the obiects (since it has no way of knowing how these were created). getFinish (0 any memory the competitor Focus ornStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started