A new restaurant requires software to compile an identification code and to manage staff numbers - NSC Information Technology - Question 3 - 2018 - Paper 1
Question 3
A new restaurant requires software to compile an identification code and to manage staff numbers.
Do the following:
- Open the incomplete program in the Question3 ... show full transcript
Worked Solution & Example Answer:A new restaurant requires software to compile an identification code and to manage staff numbers - NSC Information Technology - Question 3 - 2018 - Paper 1
Step 1
3.1.1 Constructor
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 create a constructor for the Restaurant class, declare it as follows:
Sign up now to view full answer, or log in if you already have an account!
Answer
Define the function to get the number of employees:
function TRestaurant.getNumEmployees: Integer;
begin
Result := fNumEmployees;
end;
Step 3
3.1.3 increaseNumEmployees METHOD
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
Implement the method to increase the number of employees:
procedure TRestaurant.increaseNumEmployees(aValue: Integer);
begin
fNumEmployees := fNumEmployees + aValue;
end;
Step 4
3.1.4 compileCode METHOD
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
Create the compile code method to generate the identification code:
function TRestaurant.compileCode: String;
begin
Result := Copy(fName, 1, 1) + Copy(fName, Length(fName)-1, 2) + IntToStr(fYearOpened);
end;
Step 5
3.2.1 Button [3.2.1 - Instantiate and display object]
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
Instantiating the Restaurant object in the form:
var
newRestaurant: TRestaurant;
begin
newRestaurant := TRestaurant.create('Simply Fabulous Food', '2018', 25);
RichEdit1.Lines.Text := newRestaurant.toString;
end;
Step 6
3.2.2 Button [3.2.2 - Identification code]
97%
121 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To call the compileCode method and display the identification code:
var
idCode: String;
begin
idCode := newRestaurant.compileCode;
Edit1.Text := idCode;
end;
Step 7
3.2.3 Button [3.2.3 - Add employees]
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
Handling employee addition:
var
numToAdd: Integer;
begin
numToAdd := StrToInt(Edit2.Text);
if (getNumEmployees + numToAdd) <= maxEmployees then
begin
increaseNumEmployees(numToAdd);
ShowMessage('Employees added successfully.');
Edit3.Text := IntToStr(getNumEmployees);
end
else
ShowMessage('Exceeds maximum number of employees.');
end;