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 - NSC Information Technology - Question 3 - 2021 - Paper 1
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
Worked Solution & Example Answer: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 - NSC Information Technology - Question 3 - 2021 - Paper 1
Step 1
Button [3.2.2 - Display hiking trail details]
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To implement the toString method for displaying the hiking trail details, you should follow these steps:
Define the toString method in the HikingTrail class that formats the necessary information as a string.
Ensure that it includes:
trailName
terrainType
distance and number of days
Cost per person
For example, the output if the Amatola Hiking Trail is selected should look like: Hiking trail information: Amatola Hiking Trail: Rocky 100 km long in 6 days Cost per person: R1,500.00.
Step 2
Button [3.2.3 - Display cost]
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To implement the cost calculation based on the number of hikers, adhere to the following steps:
Use an input box to request the number of hikers in the group. You may use:
var
groupSize: Integer;
begin
groupSize := InputBox('Enter number of people in group:', 'Number of Hikers', '');
Call the calculateCost method using the formula:
cost := objHikingTrail.calculateCost(groupSize);
Display the calculated cost using a message box:
ShowMessage('Cost of the group is: R' + FloatToStr(cost));
Ensure that the cost correctly reflects the total for the number of hikers.