Question: frmGymCompetitionUnit.cpp: #include #pragma hdrstop #include frmGymCompetitionUnit.h //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource *.dfm TfrmTPG20ATClassTest1 *frmTPG20ATClassTest1; //--------------------------------------------------------------------------- __fastcall TfrmTPG20ATClassTest1::TfrmTPG20ATClassTest1(TComponent* Owner) : TForm(Owner) { frmTPG20ATClassTest1->Position = poDesktopCenter; for




frmGymCompetitionUnit.cpp:
#include #pragma hdrstop
#include "frmGymCompetitionUnit.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TfrmTPG20ATClassTest1 *frmTPG20ATClassTest1; //--------------------------------------------------------------------------- __fastcall TfrmTPG20ATClassTest1::TfrmTPG20ATClassTest1(TComponent* Owner) : TForm(Owner) { frmTPG20ATClassTest1->Position = poDesktopCenter; for (int i = 0; i
// Code Here to empty all the editboxes
FormShow(this);
} //--------------------------------------------------------------------------- void __fastcall TfrmTPG20ATClassTest1::FormShow(TObject *Sender) { lstResults->Font->Size = 11;
edtName->Clear(); edtScore1->Clear(); edtScore2->Clear(); edtScore3->Clear(); edtScore4->Clear(); // ** Question 1.1.A edtScore6->Clear(); lblAverage->Caption = "";; lblCode->Caption = "";
lstResults->Items->// ** Question 1.1.B
} //--------------------------------------------------------------------------- float TfrmTPG20ATClassTest1::calcScore(String OneDataLine) { //Sam Baloy,SBL:8,8,7,6,7,3 int ColonPos; String sTemp;
sTemp = OneDataLine.SubString(OneDataLine.Pos(":")+1, OneDataLine.Length()-OneDataLine.Pos(":"));
int i = // ** Question 1.1.C
int Lowest = -1; while // ** Question 1.1.D { arrScores[i] = StrToInt(sTemp.SubString(1,sTemp.Pos(",")-1)); sTemp = sTemp.Delete(1,sTemp.Pos(",")); i++; } arrScores[i] = // ** Question 1.1.E
float fSum = 0; Lowest = arrScores[0]; for (int j = 0; j
return (float(fSum - Lowest) / 5); } //---------------------------------------------------------------------------
String TfrmTPG20ATClassTest1::getCompCode(String OneDataLine) { String Temp;
OneDataLine = OneDataLine.Delete(1,OneDataLine.Pos(",")); Temp = // ** Question 2.1.A return Temp; } //---------------------------------------------------------------------------
void __fastcall TfrmTPG20ATClassTest1::lstResultsClick(TObject *Sender) { String CurrentListLine = // ** Question 2.1.B float S = calcScore(CurrentListLine); lblAverage->Caption = // ** Question 2.1.C lblCode->Caption = getCompCode(CurrentListLine); } //--------------------------------------------------------------------------- String TfrmTPG20ATClassTest1::generateCompCode(String NameSurname) { String Temp = ""; NameSurname = NameSurname.UpperCase();
Temp = NameSurname[1];
NameSurname = // ** Question 2.1.D
Temp = Temp + NameSurname[1];
int i = 2;
while (Temp.Length()
default: Temp = Temp + NameSurname[i]; } }
// ** Question 2.1.F
} void __fastcall TfrmTPG20ATClassTest1::btnProcessScoresToListClick(TObject *Sender) { //Sam Baloy,SBL:8,8,7,6,7,3
String Temp;
Temp = edtName->Text; Temp = Temp + ","; Temp = Temp + // ** Question 3.1.A Temp = Temp + ":"; Temp = Temp + edtScore1->Text; Temp = Temp + ","; Temp = Temp + edtScore2->Text; Temp = Temp + ","; Temp = Temp + edtScore3->Text; Temp = Temp + ","; Temp = Temp + edtScore4->Text; Temp = Temp + ","; Temp = Temp + edtScore5->Text; Temp = Temp + ","; Temp = Temp + edtScore6->Text;
// ** Question 3.1.B
} //---------------------------------------------------------------------------
void __fastcall TfrmTPG20ATClassTest1::btnWinnerClick(TObject *Sender) { float highScore; highScore = // ** Question 3.1.C String winnerDetails = lstResults->Items->Strings[0];
for (int i = 1; // ** Question 3.1.D ; i++) { if (highScore Items->Strings[i])) { highScore = // ** Question 3.1.E winnerDetails = lstResults->Items->Strings[i]; } }
ShowMessage("The winner is: " + // ** Question 3.1.F + " with an average score of " + // ** Question 3.1.G
} //---------------------------------------------------------------------------
void __fastcall TfrmTPG20ATClassTest1::btnSaveResultsToFileClick(TObject *Sender)
{ // ** Question 3.1. } //---------------------------------------------------------------------------
frmGymCompetitionUnit.h:
#ifndef frmGymCompetitionUnitH #define frmGymCompetitionUnitH //--------------------------------------------------------------------------- #include #include #include #include #include #include //--------------------------------------------------------------------------- class TfrmTPG20ATClassTest1 : public TForm { __published: // IDE-managed Components TPanel *pnlHeader; TImage *Image50; TLabel *Label38; TLabel *Label46; TLabel *Label47; TShape *Shape3; TLabel *Label2; TPanel *pnlCompetitor; TLabel *Label1; TLabel *Name; TEdit *edtName; TEdit *edtScore1; TLabel *Label3; TEdit *edtScore2; TLabel *Label4; TEdit *edtScore3; TLabel *Label5; TLabel *Label6; TEdit *edtScore4; TLabel *Label7; TEdit *edtScore5; TEdit *edtScore6; TLabel *Label8; TButton *btnProcessScoresToList; TListBox *lstResults; TLabel *Label9; TButton *btnNewCompetitor; TPanel *pnlCompFinalScore; TLabel *Label10; TLabel *Label11; TLabel *Label12; TLabel *lblCode; TLabel *lblAverage; TButton *btnWinner; TButton *btnSaveResultsToFile; void __fastcall btnNewCompetitorClick(TObject *Sender); void __fastcall FormShow(TObject *Sender); void __fastcall lstResultsClick(TObject *Sender); void __fastcall btnProcessScoresToListClick(TObject *Sender); void __fastcall btnWinnerClick(TObject *Sender); void __fastcall btnSaveResultsToFileClick(TObject *Sender); private: // User declarations
public: // User declarations __fastcall TfrmTPG20ATClassTest1(TComponent* Owner);
int arrScores[6]; float calcScore(String OneDataLine); String getCompCode(String OneDataLine); String generateCompCode(String NameSurname); }; //--------------------------------------------------------------------------- extern PACKAGE TfrmTPG20ATClassTest1 *frmTPG20ATClassTest1; //--------------------------------------------------------------------------- #endif


Gym Competition Scenario: You are going to develop an application which will determine the winner of competitors partaking in activities for a competition at their local gym. Each competitor take part in 6 activities, to which a score of 0-10 are allocated.' The final score for each competitor is the average of the 5 best activities. (i.e. the activity with the lowest score is discarded) The textfile Scores.txt which is stored in the default DEBUG folder contain the name, competitor code and the 6 scores for each of the activities the competitors competed in. Sam Baloy, SBL:8,9,7,6,7,3 Sally Nkwe, SNK: 7, 8, 9,7,6,7 Lerato Bato, LBT:6,6,7, 3, 8,5 Rose Mahlangu, RMH: 3,6,6,3,5,8 Poppy Mpilina, PMP:4, 6, 5, 4, 4,7 Strongman Pule, SPL: 6,5, 3, 7, 8, 9 A Colon() is used as a delimiter between the Competitor code and the following 6 scores, the scores are delimited with a comma (c) TPG2011 - C++ Builder for Application Development -52 2020 - LATE Comer Assignment 1 1 frmTPG20ATClass Testi Lejwe Kgolo LaGima Prototype Version CT 1 S1 2014 Competitor Name Sumar Score ! Results Sam Baloy, SBL:8,9,7,6,7,3 Saly Nkwe, SNK:7,8,9,7,6,7 Lerato Bato, LBT:6,6,7,3,8,5 Rose Mahlangu, RMH:3,6,6,3,5,8 Poppy Mpina, PMP:4,6,5,4,4,7 Strongman Pule, SPL:6,5,3,7,8,9 Competitor Score Code: Score 2 Average: Score 3 Score 4 Score 5 Score 6 Determine Winner Process Scores to Resultist >> New Competitor Save Results to Fle(Scores.bit) Read the following requirements of which some code has been implemented and other single line or part snippets have been omitted. Add the code to the on show event of the form that will populate the listbox with the content of the scores.txt file. Declare a form class integer array attribute with 6 elements named arrScores Complete the implementation code for the form class method named generateCompCode. This method receives the name of a competitor (which include the Name and the Surname) as entered in to the Name_Surname editbox and returns a competitor code. The competitor code is created as follows: Capitalise the name and surname Take the first character of the competitors name, the first character of the competitors surname and the next non vowel (not a,e,i,o,u). Spaces are ignored. Each competitor code is only 3 characters long. E.g. Sam Baloy will have a competitor code of SBL Lerato Bato will have a competitor code of LBT James Atkinson will have a competitor code of JAT The method returns the competitor code. Complete the method implementation code for the getCompCode method. This method receives one line of data from the listbox and extract and return the competitor code. E.g. the method will receive the line: Rose Mahlangu, RMH: 3,6,6,3,5, 8 and should return RMH. Add a form class method named calcScore. This method also receives one complete line of data from the listbox as a string parameter and, should return the average score of the competitor as a floating point value. This method uses the arrScores attribute. The average score for the competitor is calculated as the average score of each of the scores for each event (not including the lowest score). E.g. Lerato Bato, LBT: 6,6,7,3,8,5 - 6.4 Tip: Populate the arrScores array with each of the scores and then determine the lowest and the average. Complete the code for the [Process Score to Resultlist >>] OnClick event handler that will add the data supplied on the Competitor Panel to the results listbox. Only supply the missing code. TPG20ATClass Testt Lejwe Kgolo LaGima Competitor Score Prototype Version CT 1 51 2014 Competitor Results Sam Baloy, SBL:8,9,7,6,7,3 Name Surnar Anne de Lange Sally love, SNK:7,8,9,7,6,7 Score ! 9 Lerato Bato, LBT:6,6,7,3,8,5 Rose Mahlangu, RMH:3,6,6,3,5,8 Score 2 9 Poppy Molina, PMP:4,6,5,4,4,7 Score 3 7 Strongman Pule,SPL:6,5,3,7,8,9 Anne de Lange, ADL:9,9,7,7,4,5 Score 7 Scores + Score 5 Code: Average: Determine Winner Procam Scores to Resultat >> New Corpo Save Results to Me (Seren.be Complete the code for the OnClick event of the ListBox (IstResultsClick) that will call the appropriate methods you have created and display the data of the selected competitor on the appropriate labels on the panel as indicated in the sample screenshot below: Results Sam Baloy, SBL:8,9,7,6,7,3 Saly Nkwe SNK:7,8,9,7,6,7 Lerato Bato, LBT:6,6,73,8,5 Rose Mahlangu,RMH:3,6,6,3,5,8 Poppy Mpina, PMP:4,6,5,4,4,7 Strongman Pule,SPL:6,5,3,7,8,9 Competitor Score Code: LBT Average: 6.40 Complete the code for the OnClick event for the [Determine Winner] button that will iterate through the data of the listbox, call the appropriate methods and determine and display the winner, as indicated in the screenshot below. The winner is the competitor with the highest average score. TP.20 let Lejwe Kgolo LaGima Prototype Version CTI SI 2014 Fm Score ! Competitor Results Sam Blaky SBL:8,9,7,6,7,3 Saly Nowe SNK.7 80.76.7 Competitor Score Lerato Bato, LBT:6,6,73,8.5 Rose Mahlangu RM36,63,58 Code: LBT Poppy Mpina, PMP 4,6,5,4,4,7 Strongman Ple,SPL:6,5,3,7,8,9 Average: 6.40 Gyncopepoject The Sly SEAT who were score of 780 termine Winner Scores Ass to Me Complete the code for the on click event of the (Save Results to File] button that will save the content of the Results listbox to the scores.txt textfile to the standard default Debug folder. Default Layout CX GynCompetition Project - C++ Builder 10.3 Community Edition - frm GymCompetitionUnit.cpp File Edit Search View Refactor Project Run Component Tools Tabs Help E Windows 32-bit Structure frmGymCompetitionUnit.cpp X GynCompetition Project.cbproj - Projects cx Late Comer Assignment 1 OX Lejwe Kgolo LaGima v frm TPG20ATClass Tes btnNewCompetit ok btnSaveResults To ox btn Winner lux Label IstResults > pnlCompetitor > pnlCompFinalScc > pnlHeader Prototype Version ProjectGroup1 V GynCompetition Project.exe > Build Configurations (Debug) >Target Platforms (Win32) Win32 valfrmGymCompetitionUnit.cpp frmGymCompetitionUnit.cpp frmGymCompetitionUnit.dfm frmGymCompetitionUnit.h GynCompetition Project.cpp Competitor Results Competitor Score Name Surnar edtName Score 1 edtScore Code: code Score 2 edtScore Average: avg Score 3 edtScore Score 4 edtScore Object Insp... 4 X frm TPG20ATClassTe: V Score 5 edtScore C:\Users\#LOSTI\Downloads Compressed TPG201T_Ass1_Late_StudentDi...\frmGymCompetitionUnit.h GynCompetition Project.cbproj - Projects Data Explorer Multi-Device Preview Properkir Score 6 edtScore Determine Winner Process Scores to Resultlist >> Palette New Competitor Save Results to File (Scores.txt) Activec Align alNor AlignWi False AlphaBi False AlphaBI 255 > Anchors [akLeft,ak AutoScr False AutoSizi False BiDiMo bdLeft Tol > Borderlc [biSystery Borders bsSizeabl Border 0 Caption ignment ClientH. 474 ClientW 706 Quick Edit... Quick Edit Icon... Din Vir..sh. All shown > Standard > Additional > Win32 > System > Win 3.1 > Dialogs > Data Access > Data Controls dbExpress > Xml > LiveBindings > LiveBindings Misc > Net > Tethering Vista Dialons 191: 22 Insert frmGymCompetitionUnit.cpp | frmGymCompetitionUnith Design History = Debug File Home Share View ? 1 > This PC > Downloads > Compressed > TPG201T_Ass1_Late_StudentDISK > TPG201T_Ass1_Late_StudentDISK > Win32 > Debug Search Debug Name Date modified Type Size * Quick access Scores 2014/02/24 05:25 Text Document 1 KB OneDrive This PC 3D Objects Desktop Documents Downloads Scores - Notepad File Edit Format View Help Sam Baloy, SBL:8,9,7,6,7,3 Sally Nkwe, SNK:7,8,9,7,6,7 Lerato Bato, LBT:6,6,7,3,8,5 Rose Mahlangu, RMH:3,6,6,3,5,8 Poppy Mpilina, PMP:4,6,5,4,4,7 Strongman Pule, SPL:6,5,3,7,8,9 Music Pictures Videos Local Disk (C:) System Reserved (D Local Disk (F:) - Local Disk (H:) Network Catch! Ln 1, Col 1 100% Windows (CRLF) UTF-8 1 item | 1 item selected 176 bytes | Gym Competition Scenario: You are going to develop an application which will determine the winner of competitors partaking in activities for a competition at their local gym. Each competitor take part in 6 activities, to which a score of 0-10 are allocated.' The final score for each competitor is the average of the 5 best activities. (i.e. the activity with the lowest score is discarded) The textfile Scores.txt which is stored in the default DEBUG folder contain the name, competitor code and the 6 scores for each of the activities the competitors competed in. Sam Baloy, SBL:8,9,7,6,7,3 Sally Nkwe, SNK: 7, 8, 9,7,6,7 Lerato Bato, LBT:6,6,7, 3, 8,5 Rose Mahlangu, RMH: 3,6,6,3,5,8 Poppy Mpilina, PMP:4, 6, 5, 4, 4,7 Strongman Pule, SPL: 6,5, 3, 7, 8, 9 A Colon() is used as a delimiter between the Competitor code and the following 6 scores, the scores are delimited with a comma (c) TPG2011 - C++ Builder for Application Development -52 2020 - LATE Comer Assignment 1 1 frmTPG20ATClass Testi Lejwe Kgolo LaGima Prototype Version CT 1 S1 2014 Competitor Name Sumar Score ! Results Sam Baloy, SBL:8,9,7,6,7,3 Saly Nkwe, SNK:7,8,9,7,6,7 Lerato Bato, LBT:6,6,7,3,8,5 Rose Mahlangu, RMH:3,6,6,3,5,8 Poppy Mpina, PMP:4,6,5,4,4,7 Strongman Pule, SPL:6,5,3,7,8,9 Competitor Score Code: Score 2 Average: Score 3 Score 4 Score 5 Score 6 Determine Winner Process Scores to Resultist >> New Competitor Save Results to Fle(Scores.bit) Read the following requirements of which some code has been implemented and other single line or part snippets have been omitted. Add the code to the on show event of the form that will populate the listbox with the content of the scores.txt file. Declare a form class integer array attribute with 6 elements named arrScores Complete the implementation code for the form class method named generateCompCode. This method receives the name of a competitor (which include the Name and the Surname) as entered in to the Name_Surname editbox and returns a competitor code. The competitor code is created as follows: Capitalise the name and surname Take the first character of the competitors name, the first character of the competitors surname and the next non vowel (not a,e,i,o,u). Spaces are ignored. Each competitor code is only 3 characters long. E.g. Sam Baloy will have a competitor code of SBL Lerato Bato will have a competitor code of LBT James Atkinson will have a competitor code of JAT The method returns the competitor code. Complete the method implementation code for the getCompCode method. This method receives one line of data from the listbox and extract and return the competitor code. E.g. the method will receive the line: Rose Mahlangu, RMH: 3,6,6,3,5, 8 and should return RMH. Add a form class method named calcScore. This method also receives one complete line of data from the listbox as a string parameter and, should return the average score of the competitor as a floating point value. This method uses the arrScores attribute. The average score for the competitor is calculated as the average score of each of the scores for each event (not including the lowest score). E.g. Lerato Bato, LBT: 6,6,7,3,8,5 - 6.4 Tip: Populate the arrScores array with each of the scores and then determine the lowest and the average. Complete the code for the [Process Score to Resultlist >>] OnClick event handler that will add the data supplied on the Competitor Panel to the results listbox. Only supply the missing code. TPG20ATClass Testt Lejwe Kgolo LaGima Competitor Score Prototype Version CT 1 51 2014 Competitor Results Sam Baloy, SBL:8,9,7,6,7,3 Name Surnar Anne de Lange Sally love, SNK:7,8,9,7,6,7 Score ! 9 Lerato Bato, LBT:6,6,7,3,8,5 Rose Mahlangu, RMH:3,6,6,3,5,8 Score 2 9 Poppy Molina, PMP:4,6,5,4,4,7 Score 3 7 Strongman Pule,SPL:6,5,3,7,8,9 Anne de Lange, ADL:9,9,7,7,4,5 Score 7 Scores + Score 5 Code: Average: Determine Winner Procam Scores to Resultat >> New Corpo Save Results to Me (Seren.be Complete the code for the OnClick event of the ListBox (IstResultsClick) that will call the appropriate methods you have created and display the data of the selected competitor on the appropriate labels on the panel as indicated in the sample screenshot below: Results Sam Baloy, SBL:8,9,7,6,7,3 Saly Nkwe SNK:7,8,9,7,6,7 Lerato Bato, LBT:6,6,73,8,5 Rose Mahlangu,RMH:3,6,6,3,5,8 Poppy Mpina, PMP:4,6,5,4,4,7 Strongman Pule,SPL:6,5,3,7,8,9 Competitor Score Code: LBT Average: 6.40 Complete the code for the OnClick event for the [Determine Winner] button that will iterate through the data of the listbox, call the appropriate methods and determine and display the winner, as indicated in the screenshot below. The winner is the competitor with the highest average score. TP.20 let Lejwe Kgolo LaGima Prototype Version CTI SI 2014 Fm Score ! Competitor Results Sam Blaky SBL:8,9,7,6,7,3 Saly Nowe SNK.7 80.76.7 Competitor Score Lerato Bato, LBT:6,6,73,8.5 Rose Mahlangu RM36,63,58 Code: LBT Poppy Mpina, PMP 4,6,5,4,4,7 Strongman Ple,SPL:6,5,3,7,8,9 Average: 6.40 Gyncopepoject The Sly SEAT who were score of 780 termine Winner Scores Ass to Me Complete the code for the on click event of the (Save Results to File] button that will save the content of the Results listbox to the scores.txt textfile to the standard default Debug folder. Default Layout CX GynCompetition Project - C++ Builder 10.3 Community Edition - frm GymCompetitionUnit.cpp File Edit Search View Refactor Project Run Component Tools Tabs Help E Windows 32-bit Structure frmGymCompetitionUnit.cpp X GynCompetition Project.cbproj - Projects cx Late Comer Assignment 1 OX Lejwe Kgolo LaGima v frm TPG20ATClass Tes btnNewCompetit ok btnSaveResults To ox btn Winner lux Label IstResults > pnlCompetitor > pnlCompFinalScc > pnlHeader Prototype Version ProjectGroup1 V GynCompetition Project.exe > Build Configurations (Debug) >Target Platforms (Win32) Win32 valfrmGymCompetitionUnit.cpp frmGymCompetitionUnit.cpp frmGymCompetitionUnit.dfm frmGymCompetitionUnit.h GynCompetition Project.cpp Competitor Results Competitor Score Name Surnar edtName Score 1 edtScore Code: code Score 2 edtScore Average: avg Score 3 edtScore Score 4 edtScore Object Insp... 4 X frm TPG20ATClassTe: V Score 5 edtScore C:\Users\#LOSTI\Downloads Compressed TPG201T_Ass1_Late_StudentDi...\frmGymCompetitionUnit.h GynCompetition Project.cbproj - Projects Data Explorer Multi-Device Preview Properkir Score 6 edtScore Determine Winner Process Scores to Resultlist >> Palette New Competitor Save Results to File (Scores.txt) Activec Align alNor AlignWi False AlphaBi False AlphaBI 255 > Anchors [akLeft,ak AutoScr False AutoSizi False BiDiMo bdLeft Tol > Borderlc [biSystery Borders bsSizeabl Border 0 Caption ignment ClientH. 474 ClientW 706 Quick Edit... Quick Edit Icon... Din Vir..sh. All shown > Standard > Additional > Win32 > System > Win 3.1 > Dialogs > Data Access > Data Controls dbExpress > Xml > LiveBindings > LiveBindings Misc > Net > Tethering Vista Dialons 191: 22 Insert frmGymCompetitionUnit.cpp | frmGymCompetitionUnith Design History = Debug File Home Share View ? 1 > This PC > Downloads > Compressed > TPG201T_Ass1_Late_StudentDISK > TPG201T_Ass1_Late_StudentDISK > Win32 > Debug Search Debug Name Date modified Type Size * Quick access Scores 2014/02/24 05:25 Text Document 1 KB OneDrive This PC 3D Objects Desktop Documents Downloads Scores - Notepad File Edit Format View Help Sam Baloy, SBL:8,9,7,6,7,3 Sally Nkwe, SNK:7,8,9,7,6,7 Lerato Bato, LBT:6,6,7,3,8,5 Rose Mahlangu, RMH:3,6,6,3,5,8 Poppy Mpilina, PMP:4,6,5,4,4,7 Strongman Pule, SPL:6,5,3,7,8,9 Music Pictures Videos Local Disk (C:) System Reserved (D Local Disk (F:) - Local Disk (H:) Network Catch! Ln 1, Col 1 100% Windows (CRLF) UTF-8 1 item | 1 item selected 176 bytes |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
