NATIONAL SENIOR CERTIFICATE GRADE12

Similar documents
NATIONAL SENIOR CERTIFICATE GRADE12

NATIONAL SENIOR CERTIFICATE GRADE 12

NATIONAL SENIOR CERTIFICATE GRADE12

NATIONAL SENIOR CERTIFICATE GRADE12

GRADE 12 SEPTEMBER 2012 INFORMATION TECHNOLOGY P1 MEMORANDUM

NATIONAL SENIOR CERTIFICATE GRADE12

NATIONAL SENIOR CERTIFICATE GRADE 12

GRADE/GRAAD 11 NOVEMBER 2013 INFORMATION TECHNOLOGY P1 INLIGTINGSTEGNOLOGIE V1 MEMORANDUM

NATIONAL SENIOR CERTIFICATE GRADE 12

NATIONAL SENIOR CERTIFICATE GRADE 12

SENIOR CERTIFICATE EXAMINATION

GRADE 11 NOVEMBER 2012 INFORMATION TECHNOLOGY P1 INLIGTINGSTEGNOLOGIE V1 MEMORANDUM

LAMPIRAN Listing Program

NATIONAL SENIOR CERTIFICATE GRADE 12

NATIONAL SENIOR CERTIFICATE GRADE 12

2. Design and Development

PROVINCIAL EXAMINATION INFORMATION TECHNOLOGY PAPER 1 JUNE 2015 GRADE 11

uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ImgList, StdCtrls, Buttons, MPlayer;

NATIONAL SENIOR CERTIFICATE GRADE 12

DELPHI FOR ELECTRONIC ENGINEERS. Part 2 Programming a calculator COURSE

LAMPIRAN A: LIST PROGRAM

NATIONAL SENIOR CERTIFICATE GRADE 12

NATIONAL SENIOR CERTIFICATE GRADE 12

APPLICATION NOTE: KONSTANTER LSP32K Interface Protocol

NATIONAL SENIOR CERTIFICATE GRADE 12

NATIONAL SENIOR CERTIFICATE GRADE 12 INFT.1 INFORMATION TECHNOLOGY P1 FEBRUARY/MARCH 2010

Image. uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls ;

MARK SCHEME for the October/November 2015 series 9691 COMPUTING. 9691/23 Paper 2 (Written Paper), maximum raw mark 75

NATIONAL SENIOR CERTIFICATE GRADE 12

Delphi Generics.Collections

NATIONAL SENIOR CERTIFICATE GRADE 12

Source code for simulations: 1 of 11

(1) Trump (1) Trump (2) (1) Trump ExampleU ExampleP (2) Caption. TrumpU (2) Caption. (3) Image FormTrump. Top 0 Left 0.

Interdisciplinary relations in teaching of programming

NATIONAL SENIOR CERTIFICATE GRADE 12

Использование ассиметричных алгоритмов криптографического преобразования информации в приложениях Windows

NATIONAL SENIOR CERTIFICATE GRADE 12

NATIONAL SENIOR CERTIFICATE GRADE 12

GCE AS and A Level. Computing. AS exams 2009 onwards A2 exams 2010 onwards. Unit 1: Approved specimen question paper. Version 1.1

Software Systems Development Unit AS1: Introduction to Object Oriented Development

LAMPIRAN. uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, XPMan, ExtCtrls, jpeg;

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

NATIONAL SENIOR CERTIFICATE GRADE 12

9691 COMPUTING. 9691/22 Paper 2 (Written Paper), maximum raw mark 75

Object Oriented Programming in C#

Coding Standards Document

Windows. mine sweeper Jirai JiraiU.pas JiraiP.dpr. Form Name FormJirai Caption Position podesktopcenter 16.3

SEMESTER 1, 2011 EXAMINATIONS. CITS1200 Java Programming FAMILY NAME: GIVEN NAMES:

UJIAN AKHIR SEMESTER TEKNIK INFORMATIKA SEKOLAH TINGGI TEKNOLOGI DUTA BANGSA

MARK SCHEME for the October/November 2015 series 9691 COMPUTING. 9691/22 Paper 2 (Written Paper), maximum raw mark 75

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and More

Cambridge International General Certificate of Secondary Education 0478 Computer Science June 2015 Principal Examiner Report for Teachers

LAMPIRAN A: DDL DATABASE

CSE 131 Introduction to Computer Science Fall Exam II

In Delphi script, when values are assigned to variables, the colon-equal operator is used; :=

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

Introduction to the DLL for the USB Interface Board K8061

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

CS100M November 30, 2000

static String usersname; public static int numberofplayers; private static double velocity, time;

NATIONAL SENIOR CERTIFICATE GRADE 12

var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin ListBox1.Items.LoadFromFile('d:\brojevi.

9691 COMPUTING. 9691/23 Paper 2 (Written Paper), maximum raw mark 75

Recommended Group Brainstorm (NO computers during this time)

SENIOR CERTIFICATE EXAMINATION GRADE 12

Programming Language. Functions. Eng. Anis Nazer First Semester

Cambridge International Examinations Cambridge International Advanced Level

Variables and Functions. ROBOTC Software

LAMPIRAN A. Listing Program. Program pada Borland Delphi 7.0 A-1 Program pada CodeVisionAVR C Compiler A-6

UNIT Files. Procedure/Functionand Other Declarations (CONST, TYPE, VAR) can be stored under different Object Pascal Files (Library).

The while Loop 4/6/16 4

LAMPIRAN 1 TATA CARA PENGGUNAAN SOFTWARE ALGORITMA GENETIKA

LAMPIRAN A. Foto Alat

Topic 7: Algebraic Data Types

Software Development Techniques. 26 November Marking Scheme

Systems and Principles Unit Syllabus

BASIC ELEMENTS OF A COMPUTER PROGRAM

HUDSONVILLE HIGH SCHOOL COURSE FRAMEWORK

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)

Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level

Final Exam. COMP Summer I June 26, points

Introduction to Programming using C++

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

Cambridge Assessment International Education Cambridge International General Certificate of Secondary Education. Published

New York University Introduction to Computer Science Exam Sample Problems 2013 Andrew I. Case. Instructions:

M11/5/COMSC/HP2/ENG/TZ0/XX/M MARKSCHEME. May 2011 COMPUTER SCIENCE. Higher Level. Paper pages

GCSE Computer Science

Kada se pokrene forma da bude plave boje. Dugme Crtaj krugove da iscrtava slučajan broj N krugova istog poluprečnika r (1/4 visine forme) čiji su

CPSC 233: Assignment 4 (Due March 26 at 4 PM)

CS313D: ADVANCED PROGRAMMING LANGUAGE

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

Cambridge Assessment International Education Cambridge International Advanced Subsidiary and Advanced Level. Published

ServiceNow Certified System Administrator Exam Specification

Ticket Machine Project(s)

Transcription:

NATIONAL SENIOR CERTIFICATE GRADE12 INFORMATION TECHNOLOGY P1 FEBRUARY/MARCH 2018 MARKING GUIDELINES MARKS: 150 These marking guidelines consist of 21 pages.

Information Technology/P1 2 DBE/Feb. Mar. 2018 GENERAL INFORMATION These marking guidelines must be used as the basis for the marking session. They were prepared for use by markers. All markers are required to attend a rigorous standardisation meeting to ensure that the guidelines are consistently interpreted and applied in the marking of candidates' work. Note that learners who provide an alternate correct solution to that given as example of a solution in the marking guidelines will be given full credit for the relevant solution, unless the specific instructions in the question paper were not followed or the requirements of the question were not met. Annexures A, B and C (pages 3 8) include the marking grid for each question and a table for a summary of the learner s marks. Annexures D, E, and F (pages 9 21) contain examples of a programming solution for QUESTION 1 to QUESTION 3 in programming code. Copies of Annexures A, B and C (pages 3 8) and the summary of learner s marks (page 8) should be made for each learner and completed during the marking session.

Information Technology/P1 3 DBE/Feb. Mar. 2018 ANNEXURE A SECTION A QUESTION 1: MARKING GRID GENERAL PROGRAMMING SKILLS CENTRE NUMBER: QUESTION EXAMINATION NUMBER: DESCRIPTION A learner must be penalised only once if the same error is repeated. 1.1 [Button 1.1 Total area] Extract the radius convert to real Extract the base and height from edit boxes Area of circle = pi * Sqr(radius) Area of triangles = 0.5 * base * height * number of triangles Display the area of circle with label Display the area of triangles in total Calculate total area of circle and triangles Display the total area to 2 decimal places 1.2 [Button 1.2 Next blue moon] Find position of colon in label Extract moonyear from label and convert to integer Repeat Add 3 to the moonyear Until moonyear > year of the current system date Display moonyear Correct loop example repeat...until 1.3 [Button 1.3 Highest common factor] Extract number 1 from edit box convert to integer Extract number 2 from edit box Loop x from 1 to Minimum (number1,number2) Test if (number mod x = 0) AND (number2 mod x =0) Set hcf to x Display hcf in the edit box 1.4 Button [1.4 Remove vowels] Extract sentence from edit box Set a temp iable to first character of sentence Loop x from 2 to length of sentence if (sent[x - 1] = ' ') OR NOT(upcase (sent[x]) in ['A', 'E', 'I', 'O', 'U']) temp = temp + sent[x] Display temp in edit box MAX. MARKS 12 9 10 11 LEARNER'S MARKS

Information Technology/P1 4 DBE/Feb. Mar. 2018 1.5 [Button 1.5 Slide show] for initialising total and group number Set total = 0 Set group number = 0 Use a loop to test if total < SeatsAvailable(constant given) Use an input box to enter the number of people If number of people in group <= (seatsavailable - total) Increment group number Increment total by the number of people Display group number and number of people Else Display message with correct values End of loop 12 TOTAL SECTION A: 54

Information Technology/P1 5 DBE/Feb. Mar. 2018 ANNEXURE B SECTION B QUESTION 2: MARKING GRID - OBJECT-ORIENTED PROGRAMMING CENTRE NUMBER: QUESTION 2.1.1 Constructor: DESCRIPTION EXAMINATION NUMBER: Heading with ONLY four values with Three string parameters and one real Assign parameter values to four attributes Assign false to fnavigationalstatus attribute 2.1.2 accessor METHOD: Constellation: return type string returns attribute 2.1.3 setnavigationalstatus PROCEDURE: Using a procedure (not function) Receive Boolean value Set value of fnavigationalstatus attribute 2.1.4 determinevisibility FUNCTION: If distance less than 80 Clearly visible Else {distance >= 80} If distance <= 900 If magnitude <= 2 Hardly visible to the naked eye Else {magnitude >2} Visible by means of standard optical aid Else {distance > 900} Only visible by means of specialised optical aid Set result to visibility value 2.1.5 tostring METHOD Add attributes to output string - name, constellation, magnitude and light years with correct labels If star is navigational star Add star name is a navigational star. to message Else Add star name is a passive star. to message Set result to concatenated string MAX. MARKS 4 2 3 11 6 LEARNER'S MARKS

Information Technology/P1 6 DBE/Feb. Mar. 2018 2.2.1 Button [2.2.1 - Search holder]: Extract the name of the star from the combo box Assign and reset Initialise Flag/Counter Conditional loop (while/repeat) NOT EOF & NOT Found Read line from text file Compare if line = name of star Read THREE lines from text file Instantiate star object - Create objstarx (param) Correct number and order of parameters objstarx := TStar.Create(parameters) Boolean iable set to false to search array Loop from 1 to length of array Test if star name contained in array Set Boolean iable to true Call set method for navigational star, using result of Boolean iable as parameter Change flag to true Enable panel pnlbuttons 24 Test if star is NOT found: Display message Activate tab sheet 2 CloseFile 2.2.2 Button [2.2.2 - Display]: Using tostring method to display object Load constellation picture from file and display 2.2.3 Button [2.2.3 - Visibility]: Use the star object to call methods: objstar.getname objstar.determinevisibility Display in correct format TOTAL SECTION B: 56 3 3

Information Technology/P1 7 DBE/Feb. Mar. 2018 ANNEXURE C SECTION C QUESTION 3: MARKING GRID PROBLEM SOLVING PROGRAMMING CENTRE NUMBER: QUESTION 3.1 Button [3.1 Start game] EXAMINATION NUMBER: DESCRIPTION Read level of difficulty from radio group Test for level and assign number of planets to iable Level 1 (50); Level 2 (40); Level 3 (30) Display 0 on panel; set ItemIndex of combo boxes to 0 Clear output area for incorrect guesses Initialise iables for counters Populate: Populate array with - using loops for rows and columns Repeat correct number of times (while/repeat) to: Determine random position row and column Test if position does not contain planet and.. place # in position decrease planets to be placed Display: Clear game board output area Loop through rows Create output string Loop through columns If it is a planet, add # to output string Else add - to output string Display output string in game board Enable play button 3.2 Button [3.2 - Play] Accept row and column from combo box Increment number of guesses Find character at the position in array Test if character is a planet Replace with place holder Else Display row and column in area for incorrect guesses Update display on game board Display number of guesses and on panel If two planets are found display Won message Else display Lost message. MAX. MARKS 22 13 LEARNER'S MARKS

Information Technology/P1 8 DBE/Feb. Mar. 2018 3.3 Button [3.3 Reveal planets] Loop through rows Create output string Loop through columns Add array value to output string Display output string 5 TOTAL SECTION C: 40 SUMMARY OF LEARNER'S MARKS: CENTRE NUMBER: EXAMINATION NUMBER: SECTION A SECTION B SECTION C QUESTION 1 QUESTION 2 QUESTION 3 GRAND TOTAL MAX. MARKS 54 56 40 150 LEARNER'S MARKS

Information Technology/P1 9 DBE/Feb. Mar. 2018 ANNEXURE D: SOLUTION FOR QUESTION 1 unit Question1_U; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, jpeg, DateUtils, Math; type TfrmQ1 = class(tform) PageControl1: TPageControl; TabSheet1: TTabSheet; TabSheet2: TTabSheet; Image1: TImage; btnq1_1: TButton; redq1_1: TRichEdit; edtradius: TEdit; edtbase: TEdit; edtheight: TEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label7: TLabel; lblinfo: TLabel; Label9: TLabel; edtques1_2: TEdit; btnq1_2: TButton; Image2: TImage; TabSheet4: TTabSheet; TabSheet5: TTabSheet; TabSheet6: TTabSheet; edtsentence: TEdit; Label10: TLabel; btnq1_4: TButton; edtremovevowels: TEdit; Label11: TLabel; Label12: TLabel; edtnum1: TEdit; edtnum2: TEdit; btnq1_3: TButton; edthcf: TEdit; redques1_5: TRichEdit; btnq1_5: TButton; procedure btnq1_1click(sender: TObject); procedure btnq1_2click(sender: TObject); procedure btnq1_3click(sender: TObject); procedure btnq1_5click(sender: TObject); procedure btnq1_4click(sender: TObject); private { Private declarations } public { Public declarations }

Information Technology/P1 10 DBE/Feb. Mar. 2018 frmq1: TfrmQ1; implementation {$R *.dfm} // Question 1.1 procedure TfrmQ1.btnQ1_1Click(Sender: TObject); Const rpi = 3.14159; inumber = 8; Var rradius, rareacircle, rbase, rheight, rareatriangles, rtotalarea: real; rradius := StrToFloat(edtRadius.Text); rbase := StrToFloat(edtBase.Text); rheight := StrToFloat(edtHeight.Text); rareacircle := rpi * Sqr(rRadius); redq1_1.lines.add('area of circle = ' + FloatToStr(rAreaCircle)); rareatriangles := 0.5 * rbase * rheight * inumber; redq1_1.lines.add('total area of triangles = '+ FloatToStr(rAreaTriangles)); rtotalarea := rareacircle + rareatriangles; redq1_1.lines.add('total area = ' + FloatToStrF(rTotalArea, fffixed, 6, 2)); // Question 1.2 procedure TfrmQ1.btnQ1_2Click(Sender: TObject); Const iincrease = 3; Var ddate: TDateTime; icolon, imoonyear: integer; icolon := pos(':',lblinfo.caption); imoonyear := StrToInt(copy(lblInfo.Caption, icolon+1, 4)); repeat imoonyear := imoonyear + iincrease; until imoonyear > YearOf(now); edtques1_2.text := IntToStr(iMoonYear);

Information Technology/P1 11 DBE/Feb. Mar. 2018 // Question 1.3 procedure TfrmQ1.btnQ1_3Click(Sender: TObject); Var inum1, inum2, ihcf, iloop, i: integer; inum1 := StrToInt(edtNum1.Text); inum2 := StrToInt(edtNum2.Text); for i := 1 to Min(iNum1, inum2) do if (inum1 mod i = 0) and (inum2 mod i = 0) then ihcf := i; edthcf.text := IntToStr(iHcf); // Question 1.4 procedure TfrmQ1.btnQ1_4Click(Sender: TObject); Var ssent, stemp: String; i: integer; ssent := edtsentence.text; stemp := ssent[1]; for i := 2 to length(ssent) do if (ssent[i - 1] = ' ') OR NOT(upcase(sSent[i]) in ['A', 'E', 'I', 'O', 'U']) then stemp := stemp + ssent[i]; edtremovevowels.text := stemp; // Question 1.5 procedure TfrmQ1.btnQ1_5Click(Sender: TObject); Const iseatsavailable = 100; Var igroupnumber, inumpeople, itotal: integer; // Provided code redques1_5.clear; redques1_5.lines.add('group number' + #9#9 + 'Number of people'); itotal := 0; igroupnumber := 0;

Information Technology/P1 12 DBE/Feb. Mar. 2018 while itotal < iseatsavailable do inumpeople := StrToInt(Inputbox('', 'Enter the number of people in the group', '')); if inumpeople <= (iseatsavailable - itotal) then Inc(iGroupNumber); Inc(iTotal,iNumPeople); redques1_5.lines.add(inttostr(igroupnumber) + #9#9#9 + IntToStr(iNumPeople)); end //if else ShowMessage('Cannot accept a group of ' + IntToStr(iNumPeople) + ' people' + #13 + 'Number of seats available is ' + IntToStr(100 - itotal)); //else //while end.

Information Technology/P1 13 DBE/Feb. Mar. 2018 ANNEXURE E: SOLUTION FOR QUESTION 2 OBJECT CLASS: unit Star_U; interface type TStar = class(tobject) private // Provided code - attribute declaration fname: String; fmagnitude: real; fdistance: integer; fconstellation: String; fnavigationalstatus: Boolean; public constructor Create(Name: String; Magnitude: real; Distance: integer; Constellation: String); function getconstellation: String; procedure setnavigationalstatus(bstatus: Boolean); function determinevisibilty: String; function tostring: String; // Provided code function getname: String; implementation Uses Math, SysUtils; {$R+} // Question 2.1.1 constructor TStar.Create(sName: String; rmagnitude: real; idistance: integer; sconstellation: String); fname := sname; fmagnitude := rmagnitude; fdistance := idistance; fconstellation := sconstellation; fnavigationalstatus := false; // Question 2.1.2 function TStar.getConstellation: String; result := fconstellation;

Information Technology/P1 14 DBE/Feb. Mar. 2018 // Question 2.1.3 procedure TStar.setNavigationalStatus(bStatus: Boolean); fnavigationalstatus := bstatus; // Question 2.1.4 function TStar.determineVisibilty: String; svisibility: String; if (fdistance < 80)then svisibility := 'Clearly visible' else if (fdistance <= 900) then if (fmagnitude <= 2)then svisibility := 'Hardly visible to the naked eye' else svisibility := 'Only visible by means of standard optical aid' else svisibility := 'Only visible by means of specialised optical aid'; Result := svisibility; // Question 2.1.5 function TStar.toString: String; soutput: String; soutput := Format('%s belongs to the' + ' %s constellation.' + #13 + #13 + 'The star has a magnitude of %3.2f and is %d light years away from Earth.' + #13+ #13, [fname, fconstellation, fmagnitude, fdistance]); if fnavigationalstatus then soutput := soutput + fname + ' is a navigational star.' else soutput := soutput + fname + ' is a passive star.'; result := soutput; // Provided code function TStar.getName: String; result := fname; end.

Information Technology/P1 15 DBE/Feb. Mar. 2018 MAIN FORM UNIT: QUESTION2_U.PAS unit Question2_U; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, jpeg, Star_U; type TfrmQ2 = class(tform) bmbclose: TBitBtn; btnq2_2_1: TButton; redoutput: TRichEdit; lblheading: TLabel; cmbstar: TComboBox; imgq2: TImage; pnlbuttons: TPanel; lblqstnum: TLabel; btnq2_2_2: TButton; btnq2_2_3: TButton; procedure FormCreate(Sender: TObject); procedure FormCanResize(Sender: TObject; NewWidth, NewHeight: Integer; Resize: Boolean); procedure cmbstarchange(sender: TObject); procedure btnq2_2_1click(sender: TObject); procedure btnq2_2_2click(sender: TObject); procedure btnq2_2_3click(sender: TObject); private { Private declarations } public { Public declarations } frmq2: TfrmQ2; // Provided code objstarx: TStar; implementation arrnavigationstars: array [1.. 58] of String = ( 'Alpheratz','Ankaa','Schedar','Diphda','Achernar','Hamal','Acamar', 'Menkar','Mirfak','Aldebaran','Rigel','Capella','Bellatrix','Elnath', 'Alnilam','Betelgeuse','Canopus','Sirius','Adhara','Procyon','Pollux', 'Avior','Suhail','Miaplacidus','Alphard','Regulus','Dubhe','Denebola', 'Gienah','Acrux','Gacrux','Alioth','Spica','Alkaid','Hadar','Menkent', 'Rigil Kentaurus','Arcturus','Zubenelgenubi','Kochab','Alphecca', 'Antares','Atria','Sabik','Shaula','Rasalhague','Eltanin', 'Kaus Australis','Vega','Nunki','Altair','Peacock','Deneb','Enif', 'Al Na''ir','Fomalhaut','Markab','Polaris'); {$R *.dfm} {$R+}

Information Technology/P1 16 DBE/Feb. Mar. 2018 // Question 2.2.1 procedure TfrmQ2.btnQ2_2_1Click(Sender: TObject); sstarname: String; tfile: textfile; sline, sconstellation: String; rmagnitude : real; bfoundfile, bfoundarray: Boolean; A, idistance : Integer; // Question 2.2.1 sstarname := cmbstar.items[cmbstar.itemindex]; AssignFile(tFile, 'StarData.txt'); Reset(tFile); bfoundfile := false; While NOT Eof(tFile) AND NOT bfoundfile do Readln(tFile, sline); if Trim(sStarName) = Trim(sLine) then Readln(tFile, rmagnitude); Readln(tFile, idistance); Readln(tFile, sconstellation); objstarx := TStar.Create(sStarName, rmagnitude, idistance, sconstellation); bfoundarray := false; for A := 1 to Length(arrNavigationStars) do If pos(arrnavigationstars[a], objstarx.getname) > 0 then bfoundarray := true; objstarx.setnavigationalstatus(bfoundarray); bfoundfile := true; pnlbuttons.show; if NOT bfoundfile then sline := 'The star was not found in the file.'; MessageDlg(sLine, mterror, [mbok], 0); pctrlq2.activepageindex := 1; pnlbuttons.hide; CloseFile(tFile); // Question 2.2.2 procedure TfrmQ2.btnQ2_2_2Click(Sender: TObject); // Question 2.2.2 redoutput.clear; //Provided code redoutput.lines.add(objstarx.tostring); imgq2.picture.loadfromfile(objstarx.getconstellation + '.jpg');

Information Technology/P1 17 DBE/Feb. Mar. 2018 // Question 2.2.3 procedure TfrmQ2.btnQ2_2_3Click(Sender: TObject); // Question 2.2.3 redoutput.clear; redoutput.paragraph.tabcount := 1; redoutput.paragraph.tab[0] := 50; redoutput.lines.add('star:' + #9 +objstarx.getname); redoutput.lines.add('visibility: ' +#9 + objstarx.determinevisibilty); {$REGION 'Provided code'} // Provided code - DO NOT CHANGE procedure TfrmQ2.cmbStarChange(Sender: TObject); redoutput.clear; pnlbuttons.hide; imgq2.picture := nil; procedure TfrmQ2.FormCanResize(Sender: TObject; NewWidth, NewHeight: Integer; Resize: Boolean); Resize := false; procedure TfrmQ2.FormCreate(Sender: TObject); CurrencyString := 'R'; pnlbuttons.hide; {$ENDREGION} end.

Information Technology/P1 18 DBE/Feb. Mar. 2018 ANNEXURE F: SOLUTION FOR QUESTION 3 unit Question3_U; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons; type TfrmQ3 = class(tform) redq3gameboard: TRichEdit; rgbq3: TRadioGroup; btnq3_1startgame: TButton; btnclose: TBitBtn; btnq3_2play: TButton; cmbrow: TComboBox; cmbcol: TComboBox; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; redq3incorrect: TRichEdit; btnq3_3reveal: TButton; Label5: TLabel; pnlq3numberofguesses: TPanel; pnlplay: TPanel; procedure btnq3_1startgameclick(sender: TObject); procedure populate; procedure display; procedure btnq3_2playclick(sender: TObject); procedure btnq3_3revealclick(sender: TObject); private { Private declarations } public { Public declarations } frmq3: TfrmQ3; inum: integer; ifound: integer = 0; icount: integer; // =================================================================== // Provided code // =================================================================== arrgame: array [1..9, 1..9] of char; implementation {$R *.dfm} {$R+}

Information Technology/P1 19 DBE/Feb. Mar. 2018 // =================================================================== // Question 3.1 // =================================================================== procedure TfrmQ3.btnQ3_1StartGameClick(Sender: TObject); ilevel: integer; // Question 3.1 ilevel := rgbq3.itemindex; case ilevel of 0: inum := 50; 1: inum := 40; 2: inum := 30; ifound := 0; icount := 0; pnlq3numberofguesses.caption := IntToStr(iFound); btnq3_2play.enabled := true; redq3incorrect.clear; cmbrow.itemindex:=0; cmbcol.itemindex:=0; populate; display; procedure TfrmQ3.populate; irow, icol: integer; for irow := 1 to Length(arrGame) do for icol := 1 to Length(arrGame) do arrgame[irow, icol] := '-'; while inum <> 0 do irow := random(9) + 1; icol := random(9) + 1; if (arrgame[irow, icol] = '-') then arrgame[irow, icol] := '#'; dec(inum);

Information Technology/P1 20 DBE/Feb. Mar. 2018 procedure TfrmQ3.display; irow, icol: integer; sline: String; redq3gameboard.clear; for irow := 1 to Length(arrGame) do sline := ''; for icol := 1 to Length(arrGame) do if arrgame[irow, icol] = '$' then sline := sline + '# ' else sline := sline + '- '; redq3gameboard.lines.add(sline); // =================================================================== // Question 3.2 // =================================================================== procedure TfrmQ3.btnQ3_2PlayClick(Sender: TObject); irow, icol: integer; cchar: char; // Question 3.2 irow := StrToInt(cmbRow.text); icol := StrToInt(cmbCol.text); cchar := arrgame[irow, icol]; Inc(iCount); if cchar = '#' then arrgame[irow, icol] := '$'; Inc(iFound); end else redq3incorrect.lines.add('r' + IntToStr(iRow) + ', C' + IntToStr(iCol)); display; pnlq3numberofguesses.caption := IntToStr(iCount); if (ifound >= 2) AND (icount <= 5) then btnq3_2play.enabled := false; ShowMessage('Game won'); if (icount >= 5) AND (btnq3_2play.enabled) then btnq3_2play.enabled := false; ShowMessage('Game lost');

Information Technology/P1 21 DBE/Feb. Mar. 2018 // =================================================================== // Question 3.3 // =================================================================== procedure TfrmQ3.btnQ3_3RevealClick(Sender: TObject); irow, icol: integer; sline: String; // Question 3.3 redq3gameboard.clear; for irow := 1 to Length(arrGame) do sline := ''; for icol := 1 to Length(arrGame) do sline := sline + arrgame[irow, icol] + ' '; redq3gameboard.lines.add(sline); end.