Question
Please help me with this entire C++ lab example. I will provide the given codes below the pictured instructions. thank you so much // olympic.h
Please help me with this entire C++ lab example. I will provide the given codes below the pictured instructions. thank you so much
// olympic.h
#ifndef _OLYMPIC_H
#define _OLYMPIC_H
#include "competitor.h"
#include "ranker.h"
#endif
-------------------------------------------------------------------------------------------------------------------------
// olympic.cpp
#include
#include
#include "olympic.h"
using namespace std;
ofstream csis;
int main() {
const int lanes = 4;
Ranker rank(lanes);
csis.open("csis.txt");
// First make a list of names and lane assignments
Competitor* starters[lanes];
starters[0] = new Competitor("EmmyLou Harris", 1);
starters[1] = new Competitor("Nanci Griffith", 2);
starters[2] = new Competitor("Bonnie Raitt", 3);
starters[3] = new Competitor("Joni Mitchell", 4);
// The race is run; now assign a time to each person
starters[0]->setTime((float)12.0);
starters[1]->setTime((float)12.8);
starters[2]->setTime((float)11.0);
starters[3]->setTime((float)10.3);
// Put everyone into the ranker
for (int i = 0; i
rank.addList(starters[i]);
// Now print out the list to make sure it's right
cout
csis
for (int i = 1; i
rank.getLane(i)->print();
// Finally, show how they finished
cout
csis
for(int i = 1; i
rank.getFinish(i)->print();
for(int i = 0; i
delete starters[i];
csis.close();
} // myset's destructor will be called automatically here
Olympic Lab The International Olympic Committe that figures out who won ra be rewritten in object-oriented style e needs your help. The computer pr You have been selected for the job needs t ces based on the timing data from each lane ne Fortunately (or perhaps not), some of the preliminary design work ha done, and the main program that inputs the data and prints it out has a been written. Your job is to write two C++ classes, Competitor and Ra to store information on competitor in a race and to rank these competitors from lowest to highest finishing time. This code should be divided into four files: competitor both declaration (h) and implementation-cpp) competitor.cpp, ranker.h, and ranker.cpp Objects of the Competitor class are initialized with the person's 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 iust record the pointer that was passed in. Note that there should be no predefined name and I ane 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 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 is passed in, or if the total number of objects passed in exceeds the pre-defined number of items, addList() should return 0; otherwise, it returns the total number of Competitor objects passed in. Items are retrieved (but not removed) from the list using two member functions: getLane () and getFinish(). Eacn accepts an integer from 1 to the number of items in the list. getLane () returns a pointer to the Competitor object in the specified lane, while getFinish returns a pointer to the competitor who finished at the specified position second, etc.). Finally, when a Ranker object is destroyed, it frees any m that it allocated for itself, but it does not delete the memory for the Compe objects (since it has no way of knowing how these were created) mpetitor Focus on Object-Oriented Programming with C++ Page 228Step 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