You are on page 1of 19

Unit 59/75??

Task one:

Web Authoring/ Computer Interfaces

Explain the key features of the event driven programs

(a)Service Oriented
Event drive programs provide a service to the user. An email will arrive when the USB is
plugged in. This usually works in the background and the user only notices it when it is
triggered.

(b) Time Driven


This occurs when a computer triggers a particular response or event to happen when a
set time is reached. An example of this could be an anti-virus starting at a certain time
of the day. The clock that has been set sends a message for the computer to respond
in a certain way. Numerous events can happen throughout the day and a list of these is
usually kept in a scheduler. An example of this could be a System backup at 6.00 pm
every Friday afternoon or an Anti-virus scan at 1.00 am each day.
Its when the control flow of the computer program is driven by a clock and is often
used by real time computing. Users to decide to add new events and how frequently to
run them/ cancel / skip / delete events.

(c)Event Handler
This is the actual code that will be run when the event has been detected. An example
is when a button (btnNext) has been clicked.
Private void btnNext click(object sender, EventArgs e)
{
MessageBox.Show(Button clicked. . . . ., Click. . .);
}
This will be the code behind the button

Ronan Cunningham

Page 1

Unit 59/75??

Web Authoring/ Computer Interfaces

(d)Trigger functions
Most event driven programs use trigger functions. These allow the handler to choose
which event needs to be run for the event which has occurred. Each and every object
has its own set range of trigger functions. Most objects have one trigger function for
each possible event that may be likely to occur. The trigger functions have to be
defined in order for it to work correctly. If this is not done then there will be no
properties or methods for that specific control. For example, after a button has been
clicked they tell the system to run private void btnNext Clicked(object sender,
EventArgs e) Which is the event handler.

(e) Events
When the keyboard button is pressed this action causes the code to be called an event.
Events can come from the user or often other sources e.g. timer, computer boot up etc.
Examples- On a form : Mouse clicks keyboard press (Up/Down)
HTML objects (Submit button, Reset button)
These kinds of tools will allow programmers to create GUI (graphical user interface)
instead of the command line interface or menu-based interfaces. GUIs are a lot easier
to use.

(F)Event loop

The event loop is a programming construct that waits for and dispatches events
or messages in a program. This happens when a request is made to some internal
or external event provider. This provider generally blocks the request until an
event has arrived. Then it calls the relevant event handler. The event-loop may
be used together with a reactor. The event provider follows the selected file
interface. The event loop almost always operates Data transfer in which signals
are sent in spurts, spaced by varying time intervals with the message originator.
Frequently the event loop forms the central control flow construct of a
program, and then it may be termed the main loop or main event loop. This title
is appropriate because such an event loop is at the highest level of control
within the program.
Ronan Cunningham

Page 2

Unit 59/75??

Web Authoring/ Computer Interfaces

A process whereby the computer is continually checking for events.


The computer works in millisecond.
1 second = 1000 milliseconds. The computer will be checking many times each second/
When an event is detected the trigger function is called, which calls the appropriate
event handler.
Example : When a button is pushed > interrupts the event loop/ The event loop calls the
trigger function. The trigger function calls the Event handler.
(g)Flexibility
A wide variety of programs can be written for many different application e.g. a program
for a burglar alarm to an accounting package.
Event driven program provides a very intuitive interface, e.g. people will find it easier
to click a button, rather than type in commands such as: loadprogramName
RunprogramName
It is easy to modify the code in an event driven program.
The programmer has a wide range of events available which gives them greater control
over how the program should respond to specific triggers and as a result of those
triggers what the code should do.
(h)Suitability for Graphical Interfaces
Even driven programming is at the center of GUIs because of the range of event
commands that are available which prove they work together well with graphic
interfaces e.g. mouse-over, keystroke, click or touch.
Event driven programming provides the working aspects to the Graphics user interface.
(i.e. the code code behind the button or the combo box) with the arrival of touch
screens mobile phones/ tablets new events like slide, pinch and swipe have been added,
These tools lets the programmers make GUIs based on Windows, icons, menus, pointers
(WIMP) rather than an interface based on menu based interfaces.

Ronan Cunningham

Page 3

Unit 59/75??

Web Authoring/ Computer Interfaces

(i)Simplicity of Programming
Most of the code for the Graphical User Interface or GUI is created automatically
when a programmer drags and drops the controls onto the form.
The problem is that it can be broken down into events that are to be recognised, so the
programmer can focus on making a code for that event handler. Example e.g private
void btnCalculate_Click(object sender, EventArgs e)
The programmer can double click the button will be placed behind the button. The
Integrated Development Environment or IDE automatically the event handler stub. This
saves on syntax errors and it can makes coding a lot easier.
Individual event handlers can be tested independently. The IDE can provide a intelli
sense which will help you avoid syntax errors.

(j) Ease of development


Event driven programming can make development a lot easier because the programmer
can drag and drop the controls like textbox, button or radio button onto the form.
The code can be changed easily.
Integrated Development Environment (IDE) (Visual Studio) reduces typing errors and
other common mistakes and this intellisense makes it easier to avoid syntax errors.
The Properties Window allows the programmer to set and change the properties of
objects more simply.

Ronan Cunningham

Page 4

Unit 59/75??

Web Authoring/ Computer Interfaces

Task 2
One of the first examples of an event driven program within an operating system is the
initial start-up process which is triggered by pressing the power button. The OS is
loaded into memory.
The OS will handle any kind of user inactivity. Examples include (double) clicking icons,
resizing windows etc. in any order the user carries them out this is what makes event
driven the best way to develop an Operating System.
Some examples include :

clicking an icon

moving an icon

dragging a window

resizing a window

dragging and dropping a selected item

clicking on a menu item

minimising or maximising a window

The OS will also deal with the effect of user interaction


like right-click on the desktop the OS will show a floating
menu.

If the user double clicks on a file to open it, the OS will


firstly open the application that the file is associated with
e.g. myWork.docx open MS Word.

Resizing a window / Minimising / Maximising

Ronan Cunningham

Page 5

Unit 59/75??

Web Authoring/ Computer Interfaces

The OS also
handles keyboard
events, which a lot
of them will pass to the running application like word while others are handled the OS
itself. E.g. crtl + alt + Del

The operating system recognises hardware events and responds to them.


Printer Jam > Inform user
USB pen inserted into USB slot

(Autoplay)

Inserting a CD
Power Off switch

Ronan Cunningham

Page 6

Unit 59/75??

Web Authoring/ Computer Interfaces

Task 3
Air conditioning
If the person using the air conditioner turns the dial or presses a button to set it at a
temperature.
Some air conditioners have seniors can if it gets too hot/cold it will change the
temperature automatically.

Smoke Alarm
Smoke alarms will warn you that there might be a fire nearby.
Smoke alarms have a built in sensor and when there is no smoke detected it will remain
off.
When smoke is detected the smoke alarm will turn on and warn you with a large rining.
If you ever wanted to test the smoke alarm all you need to do is press the smoke alarm
and wait for it to ring.

Burglar Alarm
Burglar alarms have something called contact switches which send light beams.
If a light beams send a signal around the house and it is usually connected to a door or
window.
If someone opens a door or a window contact will break with that object and a wireless
signal will be sent to the central panel and then an alarm will sound to warn the home
owners and the security company will be contacted. The owners can be contacted
through mobile.
The user can enter a code to turn off the alarm.

Bank card

Ronan Cunningham

Page 7

Unit 59/75??

Web Authoring/ Computer Interfaces

When the owner of the card enters his card into an ATM (Automated teller machine) it
will read the magnetic stripe on the back of the card and then the Arc Num screeb
tells the user to enter his/her PIN number.
When the User enters their PIN number the system will verify the user and will check
that their PIN and their Arc Num match. Then the User can decide how much money to
withdraw then pints receipt.

Washing Machine
The user puts their clothes into the washing machine and closes the door. They select
what washing programme to use.
The machine will open a inlet valve to let water in, The machine will let the water in and
based on the weighs how much water has entered. When enough water enters the valve
closes.
The is then heated and a temperature sensor will check to see if the water is hot
enough then switches off the heater.
The wash programme that the user chose will be activated and it will also display the
time on how much time is left.

Elevator
When the user presses the button to call the elevator.
If the user presses the up button the elevator will stop at his/her floor when going up.
When the user press the down button the elevator will stop at his/her floor when going
down
The elevator will not stop at the users floor while going in the opposite direction the
user wants to go. Example: The user wants to go down but the elevator is going up, the
elevator wont stop at the users floor until it starts going down. The only exception is
that if nobody is in the elevator or nobody on any other floors has called it.
Sometimes there will be a light above the elevators door to show you what floor it is at.
When the user picks a floor to go to the elevator will go to that floor and pick up
anybody else going in the same direction.

Conclusion
Ronan Cunningham

Page 8

Unit 59/75??

Web Authoring/ Computer Interfaces

These events happen in non-graphical applications. Non graphical application systems


are systems that dont have any graphical interface but instead have event driven
programs to controls to control them. They are also known as embedded systems like
burglar alarms, bank card or air conditioners, etc.

Task 4
C#
C# is similar to other programs like C, C++, Java or JavaScript thus it makes switching
between languages easier.
C# can be used for RAD (Rapid Application Development

Ronan Cunningham

Page 9

Unit 59/75??

Web Authoring/ Computer Interfaces

Data Dictionary
Variable

Data Type

Form

User for

double

Form1

The total cost of all the food

Main form

+ delivery

Form 1

The cost of delivery

Name
totalCost
deliveryCharge

double

Main form
today

staffArray

DateTime

Array of strings

Form1

Storing the current date and

Main form

time

Form Login

Storing login details


(User names)

loginCount

integer

Form Login

The number of attempts to


login

PriceHolyrood2oz

double

Form Burger

double

Form Burger

double

Form Burger

double

Form Burger

double

Form Burger

double

Form Burger

PriceHolyrood4oz
PriceHolyrood8oz
PriceAngus2oz
PriceAngus4oz
PriceAngua8oz
PriceRoyal2oz
PriceRoyal4oz
PriceRoyal8oz
PriceHonest2oz
PriceHonest4oz
PriceHonest8oz
PriceRanch2oz
PriceRanch4oz
PriceRanch8oz
Price2oz
Price4oz
Price8oz

Ronan Cunningham

Page 10

Price of the burger chosen

Unit 59/75??

Web Authoring/ Computer Interfaces

Login Form

Ask user to enter their username

LoginCount = loginCount + 1

// search the array to find if the username exists


For Loop (x = 0; x <arrayUsers.Length: x++)
If (arrayUsers[x] == username)
Open Main Form
Close Login form
endIf
end Loop
Inform user Login was unsuccessful

If (loginCount == 3)
Inform user 3 chances are up
Exit
EndIf

Order burger Main Form


User selects the burger they want
A new form appears frmBurgerDetails

Ronan Cunningham

Page 11

Unit 59/75??

Web Authoring/ Computer Interfaces

User selects burger size


User selects toppings

2oz, 4oz, 8oz


Onions, Ketchup, Bacon, Cheese, Coleslaw

User selects Calculate


If (2oz selected)
Price = x.xx
Else if (4oz selected)
Price = x.xx
Else if (80z selected)
Price = x.xx

// calculate the extras


If (onions selected)
Price += x.xx
If (Ketchup selected)
Price += x.xx

Etc.

Price, size of burger, extras are all passed back to main form.
Delivery
If user selects delivery
Add 3.00 to total

Ronan Cunningham

Page 12

Unit 59/75??

Web Authoring/ Computer Interfaces

Method of Payment
If user selects PayPal
Show website
If user selects Credit Card
Open CreditCard form

New Order
Clear all the commands
Print
Print the receipt
Exit
Close the Program

Credit Card Form


User enters credit card number
16 digits
User enters CVC
3 digits
User enters
Month CC expires
Year CC expires
Flexbility
A wide variety of programs can be written for many different application e.g. a program
for a burglar alarm to an accounting package.

Ronan Cunningham

Page 13

Unit 59/75??

Web Authoring/ Computer Interfaces

Event driven programming provides a very intuitive interface, e.g. people will find will
it easier to click a button, rather than type in commands such as: load programName
run programName.

Ronan Cunningham

Page 14

Unit 59/75??

Web Authoring/ Computer Interfaces

Task 4
Test

Data to be entered

Reason for test

Expected Result

Actual Result

Number
1

Holyrood burger (2oz)

Normal data

13.65

13.65

Normal data

12.15

12.15

Normal data

17.45

17.45

Normal data

14.90

14.90

Normal data

11.20

11.20

Normal data

12.30

12.30

12.50

12.50

14.10

14.10

With onions and bacon, delivered


2

Holyrood burger (4oz)


With ketchup and Coleslaw

Holyrood burger (8oz) With cheese and


coleslaw. delivered

Angus rare breed (2oz)


With onions, ketchup, bacon, cheese and
coleslaw, delivered

Angus rare breed(4oz)


With ketchup and cheese

Angus rare breed (8oz) With bacon

Royale with cheese(2oz) With onions,


ketchup, cheese

Royale with cheese(4oz) With ketchup and


coleslaw

Royale with cheese (8oz)

19.30

19.30

10
11

With onions and coleslaw delivered


Honest burger (2oz) With bacon and cheese
Honest burger (4oz) delivered

10.30
14.70

12.70
17.10

12

With ketchup and coleslaw


Honest burger (8oz) With onions

13.40

15.80

13
14

Ranch (2oz) With ketchup and coleslaw


Ranch (4oz) delivered With onions, bacon

13.20
18.00

13.10
18.10

15
16
17
18
19
20

and cheese
Ranch (8oz) With cheese and coleslaw
Holyrood (8oz) All toppings, delivered
Holyrood (4oz) with all toppings, delivered
Holyrood (2oz) with all toppings, delivered
Holyrood (8oz) no toppings
Holyrood (4oz) no

15.90
18.85
16.85
14.85
13.45
11.45

16.40
18.85
16.85
14.85
13.45
11.45

21

toppings
Holyrood (2oz) no toppings

9.45

9.45

22

Angus (2oz) no toppings

9.50

9.50

23

Angus (4oz) no toppings

10.50

10.50

24

Angus (8oz) no toppings

11.50

11.50

25

Ranch (2oz) no toppings

11.40

11.40

26

Ranch (4oz) no toppings

13.40

13.40

27

Ranch (8oz) no toppings

15.40

15.40

28

Honest (2oz) no toppings

11.40

11.40

Ronan Cunningham

Page 15

Unit 59/75??

Web Authoring/ Computer Interfaces

29

Honest (4oz) no toppings

13.40

13.40

30

Honest (8oz) no toppings

15.40

15.40

31

Royale with cheese(2oz)no toppings

11.40

11.40

32

Royale with cheese(4oz)no toppings

13.40

13.40

33

Royale with cheese(8oz)no toppings

15.40

15.40

34

Honest (2oz) all toppings

13.80

13.80

35

Honest (4oz) all toppings

15.80

15.80

36

Honest (8oz) all toppings

17.80

17.80

37

Ranch (2oz) all toppings

13.80

13.80

36

Honest (8oz) all toppings

17.80

17.80

38

Ranch (4oz) all toppings

15.80

15.80

39

Ranch (8oz) all toppings

17.80

17.80

40

Angus(8oz) all toppings

11.90

11.90

41

Angus(4oz) all toppings

12.90

12.90

42

Angus(8oz) all toppings

13.90

13.90

42

Royale with cheese(2oz) all toppings

13.80

13.80

43

Royale with cheese(4oz) all toppings

15.80

15.80

44

Royale with cheese(8oz) all toppings

17.80

17.80

45

Ranch(2oz) with coleslaw and cheese

12.40

12.40

46

Ranch(4oz) with coleslaw and cheese

14.40

14.40

47

Ranch(8oz) with coleslaw and cheese

16.40

16.40

48

Holyrood(2oz) no toppings delivered

12.45

12.45

49

Holyrood(4oz) no toppings delivered

14.45

14.45

50

Holyrood(8oz) no toppings delivered

16.45

16.45

Task 5
private void btnCreditcard_Click(object sender, EventArgs e)
{
rtbBill.Text += "Testing 1";
txtCost.Text = "Hello...";
MessageBox.Show("finished......");
}
private void btnOrder_Click(object sender, EventArgs e)
{

Ronan Cunningham

Page 16

Unit 59/75??

Web Authoring/ Computer Interfaces

}
private void rtbBill_TextChanged(object sender, EventArgs e)
{
}

This is the code for the text box on Form1. (Note - For some reason it is not working. I
think that the text box may be locked)

Task 6
Figure one This will be the screen that
will appear if you dont enter the staff
code correctly
MessageBox.Show("Unsuccessful Login...");
txtCode.Text = "";
txtCode.Focus();
if (LoginCount == 3)
{

Figure two This will be the screen


that will appear if they enter the
correct staff code
{
MessageBox.Show("Successful Login...");
Log_in.ActiveForm.Close();
return;
}// end if

Figure three If you enter the wrong


staff code three times a this message
will inform you that you have ran out of
login chances.
if (LoginCount == 3)
{
MessageBox.Show("You have run out of login
chances... Goodbye");
Application.Exit();

Figure four This is form 1. It is the


main screen for the website ( Note: for
some reason the text box is not
working)

Figure five This is the credit card


Ronan Cunningham

Page 17

Unit 59/75??

Web Authoring/ Computer Interfaces

screen. The user must enter his/her


credit card.

Figure six- This is the log in screen. It


will be the first screen the user will
see. The user must enter the right
code.
namespace Test4
{
public partial class Log_in : Form
{
string[] staffArray = new string[3];
int LoginCount = 0;
protected override CreateParams CreateParams
{
get
{
const int CP_NOCLOSE = 0x200;
CreateParams myCp = base.CreateParams;
myCp.ClassStyle = myCp.ClassStyle |
CP_NOCLOSE;
return myCp;

Codes
private void Log_in_Load(object sender, EventArgs e)
{
staffArray[0] = "Jane";
staffArray[1] = "Tim";
staffArray[2] = "Worker";
txtCode.Focus();
}
private void txtCode_TextChanged(object sender,
EventArgs e)

Ronan Cunningham

Page 18

Unit 59/75??

Ronan Cunningham

Web Authoring/ Computer Interfaces

Page 19

You might also like