Photo AI
Question 3
SECTION C QUESTION 3: OBJECT-ORIENTATED PROGRAMMING Information on some of the popular hiking trails in South Africa are available in the format of text files. The ... show full transcript
Step 1
Answer
To display the hiking trail details using the toString
method, write the following code:
procedure DisplayHikingTrailDetails;
begin
redQ3_2.Text := objHikingTrail.toString;
end;
This code will set the text of the redQ3_2
component to the string representation of the objHikingTrail
, which contains the name, terrain type, distance, and cost details.
Step 2
Answer
To calculate the cost for the group, implement the following steps:
procedure DisplayCost;
var
numberOfHikers: Integer;
begin
numberOfHikers := StrToInt(InputBox('Enter number of hikers in group', 'Number of Hikers', ''));
costVariable := objHikingTrail.calculateCost(numberOfHikers);
ShowMessage('Cost of group is: R' + FloatToStr(costVariable));
end;
This code prompts the user to input the number of hikers, calculates the total cost using the calculateCost
method, and then displays the result in a message box.
Report Improved Results
Recommend to friends
Students Supported
Questions answered