Photo AI

A new restaurant requires software to compile an identification code and to manage staff numbers - NSC Information Technology - Question 3 - 2018 - Paper 1

Question icon

Question 3

A-new-restaurant-requires-software-to-compile-an-identification-code-and-to-manage-staff-numbers-NSC Information Technology-Question 3-2018-Paper 1.png

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

Answer

To create a constructor for the Restaurant class, declare it as follows:

constructor TRestaurant.create(aName: String; aYearOpened: String; aNumEmployees: Integer);
begin
    fName := aName;
    fYearOpened := aYearOpened;
    fNumEmployees := aNumEmployees;
end;

Step 2

3.1.2 getNumEmployees METHOD

99%

104 rated

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

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

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

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

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

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;

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;