Sunteți pe pagina 1din 8
UNIVERSITY EXAMINATIONS UNIVERSITEITSEKSAMENS + | Mle se, UNISA less INF2611 Mayline 2012 RIN2611 VISUAL PROGRAMMING II Dureton 2 Hours 70 Marks EXAMINERS. FIRST MRS PM GOUWS SECOND MRL ARON. This examination question paper remains the property of the University of South Africa and may not be removed from the examination venue This paper consists of 8 pages Instructions. + Answer all questions in the answer book + Answers in pencil will be marked + Marks are given in the brackets next to the question + Enyoy! INF2611 Question 1 - Menus (15) May/June 2012 a Nome two benefits of using a menu in an application (2) b_ What is the purpose of an accelerator key in @ menu? Give an example of such a key(2) € What 1s a cascading menu? Explain how this menu can be used within a pop-up or drop down menu? (2) d_ Discuss the use of menus in your database project Identify the menu types that you used, and give the menu items that you used (3) ler the following application using menus The new main menu component is called Gir i S| mnuDeleteNome | Name To prevent having to repeat the code for most of the menu tems, we use the event handlers of the existing buttons Select ame to delete | | ‘ I I e Explain how the Load menu item (giving ‘the code where required) is linked with ‘the relevant Load buttons for the re-use of an event handler (3) f What additional code 1s required to ensure that the DELETE menu item matches the behaviour of the Delete Button? Explain why this 1s necessary? (3) INF2611 lay/June 2012 ‘Question 2 - Multiple forms (15) Consider the following application to demonstrate multiple forms ‘The form 2 message ss. ediFormMeszage “A Delphi project is a collection of files that make up an application” aA Delphi project s made up of visual interfaces and code that will activate the terface A project can have multiple forms, which allow for the development of applications with multiple windows Explain two uses of the UNIT file in an application (2) b Name two different ways that you used forms in your database project Name and motivate the use of these two form formats (4) ¢ Two error messages were generated during the compilation of the multiple for ‘application Explain (with clear reference to the information provided) why the following two error messages were generated during the compilation of the project? (4) es) @ Form 'Forml' references form 'Form2' declared in unit "Uni2' which 1 notin your USES list Do you mish to add we [Information 4 INF2611 May/June 2012 Information @ For ‘Fown2' references form Forml! declared in unit “Unit which 1s not in your USES lct. Do you wish to add ” (ye7) (he d_ Give the code for Buttont on Formt (2) pea 1 Gaveetae Binet fone Zero eon Prom Se Be ‘een tt Boon ere ae [>of {einen ein Give the code for Buttonl on Form2 (3) snare 9 > GlivckonePige Buwt Bows { Crome Tet areas socom tatednion faeaain pabase applications (20) 2 What 1s a data module? Explain why a data module 1s included in a database application (2) b Nome two data components that may be included in the data module, as well as the purpose of each (2) ¢ Reporting can be used to gain information from the data im your database Explain two reports that you included in your project Aliso include relevant references to queries used and table accessed Motivate the purpose for including these in your project (4) d With reference to your database project, explain how data was retrieved from the database for manipulation within your database application You may include reference to data aware controls and connections that you specifically sed (4) INF2611 May/June 2012 The following 1s a required structure for a database application Explain in detail what code must be included in the FormShow and in the FormClose subroutines You may add specific reference to and details of your database application Code or text comments may be used to motivate the inclusion of this code in the database application (8) procedure TérnMyProject FormShow(Sender TObyect), begin //explain what code 18 required here an thie subroutane. end, procedure TérmMyProject FormClose (Sender Tobject, var Action TCloseAction) , began //explaan what code 18 required here in this subroutane. end, Question 4 - Object orientation (20) Three teams, Blue, Red and Yellow are competing in an athletics championship A win scores 10 points, second place scores 6 and third place scores 4 Each team has two competitors so that a team may, for example, score a second and a third place The application uses the following screen layout and two units to make up the pragram code Fae eRe Team Blue TeamRed Team Yellow wn | 4 wn [6 Second } Second Clear All Scores 1 unit scoreprd, 2 interface 3 uses 4 Windows, Messages, SysUtils, Classes, Graphics, CoS ntrols, 6 Dialogs, stdctris, Buttons, 7 type @ TéxmScoreboard = class (TForm) 9 gpbBlue ‘Teroupsox, 10 beawanBlue TButton, 11 IblscoreBlue —Thabel, 12 benSecondBlue Tautton, 13. benThirdBlue —_TButton, 14 {Red and Yellow have similar declarations} 15 btnClearScores Button, 16 procedure FormCreate (Sender Object) , 17 procedure btnWinBlueClick (Sender Tobject) , 18 procedure btnSecondBlueClick (Sender TObyect), 19 procedure btnThirdBlueClick (Sender TObject), 20 {Red and Yellow have similar declarations} 21 procedure btnClearScoresClick (Sender TObject) , 22 private 23 ( Private declarations } 24 public 25 { Public declarataons } 26 end, 2) var 28 frmcoreboard TfxmScoreboard, 29 implementation 30 uses Counter, 31 var 32 ScoreBlue, ScoreRed, Scorevellow TAathleticsScore, 33 (gr * DRM) 34 procedure Tfrmscoreboard FormCreate(Sender Tobject), 35 begin 36 ScoreBlue = ‘TAthLetucsScore Create, 37 ScoreRed = TathleticsScore Create, 38 ScoreYellow = TAthleticsScore Create, 39 end, // end procedure Tfrmscoreboard Formcreate INF2611 ‘May/June 2012 Forms, 40 procedure TérmScoreboard btnClearScoresClick (Sender Tobject) , 41 begin 42 IblScoreBlue Caption = IntToStr (ScoreBlue Clear), 43 IblscoreRed caption IntTostr (ScoreRed Clear), 44 IplscoreYellow Caption = IntToStr (Scorevellow Clear), 45 end, // end procedure Tfrmscoreboard brnClearscoresCl1ck 46 procedure TérmScoreboard btnWinBlueClick(Sender object), 47 begin 48 //{ See questions below } 49 end, // end procedure TfrmScoreboard btnWinBlueClick INF2611 May/June 2012 50 {The event handlers for the remaining Buttons are similar } 51 end // end unit Scoreprd Unit specifying the TCounter class and its subcl: 1 unit Counter, 2 anterface 3 type 4 TCounter = class (TObyect) 5 pravate 6 Value Integer, 7 protected 8 function Add (const Number Integer) anteger, 9 public 10 function Clear anteger, ll end, // end TCounter = class (Tobject) 12 TathleticsScore = class (TCounter) 13 public 14 function Addwin integer, 15 function AddSecond integer, 16 function AddThird integer, 17 end, // end TSoccerscore 18 amplementataon class (TCounter) 19 const 20 Wan = 10, 21 Second = 6, 22 Third = 4, 23 Clearval = 0, 24 ( Teounter methods } 25 function TCounter add (const Number Integer! 26 begin 27 //{See questions below} 28 end, // end function TCounter Add 29 function TCounter Clear anteger, 30 begin 31 Value = Clearval, 32 Result = Value, 33 end, // end function TCounter Clear 34 { Tachleticsscore methods } 35 function TAthleticsScore Addwin integer, 36 begin 37 //{See questions below} 38 end, // end function TAthleticsScore AddWin anteger, 39 //{ Methods AddSecond and AddThird are similar } 40 end // end unit Counter ‘Answer the set of questions that follow, referring where appropriate to the code above by unit name and Ime number(s) INF2611 bs “May/June 2012 Unit ScoreBrd declares a class of type TForm while unit Counter does not Why 1s this so? (2) One of the most significant characteristics of Object Orientation 1s inheritance’ Discuss this statement briefly and describe how inherrtance 1s coded in Delphi, giving examples from the program code above (4) The declaration of TCounter (unit Counter, lines 4-11) has sections marked private, protected and public What 1s the significance of these sections? (3) What are the data and methods associated with the TAthletiesScore class? (4) Explain the difference between an object and a class Give an example of each from the code given below (4) ‘The interface section has several sub-sections Names these, and describe the purpose of each of these subsections with reference to the code gwen (3) ° UNISA 2012

S-ar putea să vă placă și