The Biggest Loser
A new weight loss competition called The Biggest Loser has been initiated. The objective of this competition is winning by losing as much weight as possible on a weekly basis. The competition is made up of two teams of 5 made up of males and females namely “Blue Team” and “White Team”. A C++ program is needed to extract the stored competition information and derive certain insight from it. They need your help as a programmer to develop for them an application that will help them keep track of the competition each week.
Your system is supposed to have the following functionality:
• Retrieve weekly competition data from a csv file
• Store the retrieved data into relevant objects
• Display the retrieved competition data in the correct format
• Determine which team won on that particular week
• Determine how much weight each contestant has gained/lost for that week
• Determine a percentage of contestants who are above a certain age
• Display the analysed statists accordingly
Do not change or add to the given names for methods and data members for both classes. (Marks will be deducted if this is not adhered to).
Create a folder under D:\My Documents and name it your student number,
E.g. D:\My Documents\204101639\.
Project and files must be saved in the correct folder, and student number, surname with initials should be written as a comment on the first line in each file. Follow the instructions on the last page of this paper on how to upload your work on ec.
Question 1 (person.cpp) [27.5]
Create a class named Person that will have the following members:
Data Members:
Access Data Type Name Description
? ? name Stores a person’s name.
? ? surname Stores a person’s surname.
? ? age Stores a person’s age.
? ? weight Stores a person’s weight.
Methods:
Access Return Type Name Description
public ? ? A default constructor that will set all data members to proper initial values (Zeros or empty strings).
public ? ? A copy constructor.
public ? ? An overloaded default constructor that receives the right number of data values.
public ? setPerson(?) Receive and set arguments accordingly.
public ? getName() This method returns a person’s name.
public ? getSurname() This method returns a person’s surname.
public ? getAge() This method returns a person’s age.
public ? getWeight() This method returns a person’s weight.
public ? Operator>(?) This overloaded operator compares a person’s age against a given integer value.
Question 2 (contestant.cpp) [10.5]
Create a class named Contestant. This class inherited from the Person class and it has the following data members:
Data Members:
Access Data Type Name Description
? ? ID Stores an alphanumeric unique contestant ID.(i.e. CT5566)
? ? team A single character representing the team a contestant belongs to. B for Blue Team and W for White Team.
? ? nWeight This data member represents a contestant’s current weight in the competition for a particular.
Methods:
Access Return Type Name Description
public ? ? A default constructor that initializes all data to correct initial values.
public ? ? An overloaded default constructor that implements an initialization list to provide values for both the parent and child class.
public ? setContestant(?) Receives and sets data for a contestant.
public ? getType() This method returns the loyalty card type, “Gold” or “Platinum”.
public ? getID() This method returns a contestant ID.
public ? getTeam() This method returns the contestant’s team (B/W).
public ? getNewWeight() This method returns the contestant’s new weight for the current week in the competition.
public ? operator==(?) This overloaded operator checks which team contestant belong to given a character (B/b/W/w).Make sure the method handles both upper and lower case characters the same way.
public ? operator+(?) This overloaded operator adds up the current weight of two or more contestants.
Question 3 (Run.cpp) [18.5]
3.1 Create the following non-member functions as part of run.cpp:
• populateContestant – This function receives an array of Contestant objects, the size of that array and a file name. This function must then populate the passed array with data from a csv file called “compete.csv” shown in Figure 1.
• determineWinner – This function determines which team won the competition for that particular week. Make use of your overloaded operator to help you accomplish this. The team with the lesser total current weight of all its team members is the winner for that week. See output on Figure 2.
• countAbove – This function determines and returns the percentage of Contestants who are above a given age. Make use of your overloaded operator(s). See Figure 2.
• determineStats – This function determines and shows how much weight each contestant has gained or lost on that particular week. See output on Figure 2.
3.2 Write a main() program and save it in Run.cpp. Use this program to test your class functionality as follows:
3.2.1 Instantiate an array of 10 Contestant objects
3.2.3 Populate the array of Contestant objects. (Refer to Figure 1)
3.2.4 Display the retrieved Contestant information
3.2.5 Display which team won for that particular week.
3.2.6 Display Contestant weight loss/gain information.
3.2.7 Display the percentage of Contestants who are above 25 years.