Complete the code in the given Excursion object class (Excursion/Excursion) as described in QUESTION 2.1.1 to QUESTION 2.1.5 below - NSC Information Technology - Question 2 - 2016 - Paper 1
Question 2
Complete the code in the given Excursion object class (Excursion/Excursion) as described in QUESTION 2.1.1 to QUESTION 2.1.5 below.
2.1.1 Write a mutator method cal... show full transcript
Worked Solution & Example Answer:Complete the code in the given Excursion object class (Excursion/Excursion) as described in QUESTION 2.1.1 to QUESTION 2.1.5 below - NSC Information Technology - Question 2 - 2016 - Paper 1
Step 1
Write a mutator method called setVisitDate
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
procedure setVisitDate(date: TDateTime);
begin
visitDate := date;
end;
Step 2
Write a method called requireTourGuide
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
function requireTourGuide: string;
begin
if tourGuide then
Result := 'Yes'
else
Result := 'No';
end;
Step 3
Write a method called isConfirmed
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
function isConfirmed: Boolean;
begin
Result := (totalLearners <= 600);
end;
Step 4
Write a method called calcAmount
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
function calcAmount(costPerPerson: Currency): Currency;
var
numberFree: Integer;
totalCost: Currency;
begin
numberFree := groupSize div 10;
totalCost := (groupSize - numberFree) * costPerPerson;
Result := totalCost;
end;
Step 5
Complete the toString method
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
function toString: string;
begin
Result := 'School name: ' + schoolName + '\n';
Result := Result + 'Visit date: ' + DateToStr(visitDate) + '\n';
Result := Result + 'Number of learners: ' + IntToStr(groupSize) + '\n';
Result := Result + 'Tour guide: ' + requireTourGuide;
end;