INF2611-2010-10-E-1 - UNIVERSITY EXAMINATIONS...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: UNIVERSITY EXAMINATIONS UNIVERSITEITSEKSAMENS Q U N I SA m» alsoufiufna IN 1 Octoben‘November 2010 VISUAL PROGRAMMING 2 Duration 2 Hours 70 Marks EXAMINERS FIRST MS PM GOUWS SECOND MR KJ HALLAND _________—__,_.—.__—_———-—~—-—————-—-——-- This question paper consnsfs of 8 pages Instructions 0 Answer all queshons In The answer book 0 Answers In penal Will be marked 0 Marks are given In The bracke’rs next To The queshon 0 ENJOYI Please T111 11 0\ er 2 INF2611 October/November 2010 flsflon 1 — Menus (10) a. Explain the statement. “There are different ways of associating code with items on the menu These all lead to the most effective method where the program code and component properties are maintained centrally in Action lists." (4) b. What are a similarity and a difference between an accelerator key and a short cut? You may use a coded example to explain. (2) c. Discuss the use of menus in your database project. Identify the menu types that you uSed, as well as the functionality that these menus implemented. (4) Qu_estion 2 — Multiple forms (10) a Explain the use and Implementation of the modeless form style (2) b. From a user interface de5ign perspective, is it better to use modal or modeless forms? You may use an example to explain your answer (4) c. Discuss the use of multiple forms in your database pro Ject. Identify the form styles used and motivate the use of the different styles. (4) Mia 3 - Database applications (25) a. You are required to explain the statement: “Data and information are not the same thing" Also provnde two examples of data and two examples of information from your database project. (5) b. Explain what a data aware control is. Name at least two data aware controls that you used on the forms (i e NOT in the data module) in your database pro Ject, and explain the purpose of each of these controls in your application (5) c. How do we bring the data in a database and the application to manipulate this data together? Explain how the data is transferred from the physical database to the data aware control components. Also explain how the modified data is returned to the database. You may refer to the components and examples that you used in you database project. (5) d An excerpt from a reservations database application for a guest house (6H) in Kruger National Park (KN) is given below (at the end of this Please Turn Over INF2611 October/November 2010 question) Each reservation is tested. Give comments where indicated on code below (Comment A - Comment 6) to explain the functionality. (8) e. In the procedure TfrmGHReservation.btnAvailableClick, the input IS tested Several times. Explain why this extensive testing is required. (2) Procedure AddReservationRecord (GH,Surname,Tel: String; BDate: TDateTime); begin //CGMMENT A with dmoKNPark.tblNewReservations do begin //COMMENT B 313' Insert; //COMMENT C F1eldByName('GuestHouseName').AsString := GH; F1eldByName('BeginDate').AsDateTime := BDate; FieldByNamei'Surname').AsStrlng := Surname; FieldByNamei'Telephone').AsString := Tel; //COI\MNT D Post; ShowMessage ('Reservation done'); except on EDatabaseError do begin //COMMENT E ShowMessage ('Database error'); Delete; and; and; end: and; Function EveryThlngEntered: Boolean; //COMMENT F begin with frmGHReservation do EveryThingEntered := (dchuestHouse.Text <> ") and (DateToStr(dthDate.DateT1me) <> ") and (DateToStr(dtpEDate.DateT1me) <> "); and; Please Turn Over INF2611 October/November 2010 Function GHAvailable (GHouseName:String; BDate,EDate: TDate): Boolean; var Day: TDate; Available. Boolean; begin Available := True; if dmoKNPark.tblNewReservations.FindKey([GHouseName]) then //camment G with dmoKNPark.tblNewReservations do while (F1e1dByName('GuestHouseName').AsString = GHouseName) and (Available) do begin //Check If any day lfl the required period //falls within an already reserved time period Day := BDate; while Day <= EDate do begin if (Day >= FieldByName('BeginDate').AsDateTime) and (Day <= FieldByName('EndDate‘).AsDateTime) then Available := False; Day := Day + 1; end; Next; end; Result := Available; and; procedure TfrmGHReservation.btnAvailableClick (Sender: TObject); var GHouseName, Surname, Tel, EmailAddress: string; begin if not EveryThingEntered then ShowMessage ('Incomplete form.') else //date check9 if not (dthDate.Date < dtpEDate.Date) thben ShowMessage ('Invalid period.') else begin GHouseName := dchuestHouse.Text; //available for required period? if not GHAvallable (GHouseName,dthDate.Date,dtpEDate.Date) then //not available for full period ShowMessage ('Guest house not available for full INF261 l October/November 2010 per;od.') else begln //Get Tourist Info and subm1t or cancel frmTouristInfo.Capt10n GHouseName + ': ' + DateToStrldthDate.DateTlme): if frmTourlstInfo.ShowModal = erK then begln Surname := frmTourlstInfo.edtSurname.Text; Tel = frmTourlstInfo.edtTelephone.Text; EmallAddress := frmTourlstInfo.ethmail.Text; AddReservatlonRecord (GHouseName, Surname,Tel, dthDate.DateT1me); end: end; and: and; Question 4 - Object orientation (25) The program presents the simple ob Ject oriented traffic light shown below. The structure of a traffic light obJect IS given in the ObJect TreeView (2 Traffic Light Object TreeWew a fln'ITE-filhliingm [a lblTreferLIght E shpGreen E shpFled a shp‘n’ellow a lmlTlaflIenght unlt L1ghtControlU; //Def1nes the user interface :Lnterface uses Wlndows, Messages, SysUtlls, Varlants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, TraffchlghtU, Please Turn Over 6 INF261 l October/November 2010 type TfrmTraffchlght = c1ass(TForm) tmrTraffchlght: TTlmer; lblTraffchlght: TLabel: shpRed: TShape; shpYellow. TShape; shpGreen: TShape; procedure tmrTrafficLightTimer(Sender: TObject); procedure FormShow(Sender: TObject); private procedure UpDateDisplay; public { Public declaratlons } end; var frmTraffchlght: TfrmTraffchlght; MyTraffchlght: TTraffchight; // TTrafficnght a programmer defined Period: integer; State: strlng; Stoleght, Cautionnght, Gonght: TColor; implementatlon {3R *.dfm} procedure TfrmTraffchlght.FormShow(Sender: TObject); begin MyTraffchlght '= TTrafficLight.Create; State := 'Cautlon'; MyTrafficnght.NextState(State, Period, StopLight, CautionL1ght, Gonght); UpDatenlsplay; end; // end procedure TfrmTraffchlght.Fbrmshow procedure TfrmTraffchight.tmrTrafficnghtTlmer(Sender: TObject): begin MyTraffchlght.NextState(State, Period, Stoleght, CautlonLight, GoLight); UpDateDlsplay; end; // end procedure TfrmTraffchlght.tmrTrafficnghtTlmer procedure TfrmTrafficnght.UpDateDlsplay; beg1n tmrTraff1cL1ght.Interval := Perlod; 1blTraff1cL1ght.Caption := State; shpRed.Brush.Color := StopLight; shpYellow.Brush.Color := CautionLight; shpGreen.Brush.Color := Gonght; end; // end procedure TfrmTraffchlght.UpDateDieplay end. // end UDlt LightControlU INF2611 October/November 2010 unit TrafficLightU; //def1nes the object traffic light interface uses Graphics; // for TColor tYPG TTrafficLight class (TObject) public procedure NextState (var State: string; out Period: integer; var StopLight, CautionLight, GoLight: TColor); end; implementation { TTrafficLight } procedure TTrafficLight.NextState(var State: string; out Period: integer; var StopLight, CautionLight, GoLight: TColor); (State = 'Stop') then begin Period := 3000; State := 'Go'; StopLight := clBlack; GoLight := chreen; end else if (State = 'Go') then begin Period := 1000; State :- 'Caution’; GoLight :- clBlack; CautionLight := clYellow; — 4000: .= 'Stop'; CautionLight :- clBlack; StopLight :— clRed; end; end; // end procedure TTrafficLight.NéxtState end. // end unit TrafficLightU Please Turn Over 8 INF2611 OctoberlNovember 2010 . Explain the concept of composmon in ob Ject orientation Give an example from the code above (2) Each of the units has an interface section and an Implementation section What is the purpose of the implementation section? Give examples from the code above (2) . Each unit has a name for identification, an interface section for communication and an implementation section for the private details This Supports the ob Ject oriented Cth‘ClC‘l'eI‘IS‘l'IC of encapsulation. Motivate (2) . What is the purpose of procedure FormShow in LightControIU (lines 29- 41)“) (4) . How would you change the program so that the control of the traffic light is a user event rather than a system event? (6) . What changes are required to make the colour of the traffic lights change more frequently? Could these changes be done only at de5ign time, or can these changes be implemented so that the change happens at run-time? Explain your answer (4) © UNISA 2010 ...
View Full Document

This note was uploaded on 02/27/2012 for the course IT 101 taught by Professor Unsure during the Spring '11 term at University of South Africa.

Page1 / 8

INF2611-2010-10-E-1 - UNIVERSITY EXAMINATIONS...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online