Professional Documents
Culture Documents
Task one:
(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.
(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??
(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??
Ronan Cunningham
Page 3
Unit 59/75??
(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.
Ronan Cunningham
Page 4
Unit 59/75??
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
Ronan Cunningham
Page 5
Unit 59/75??
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
(Autoplay)
Inserting a CD
Power Off switch
Ronan Cunningham
Page 6
Unit 59/75??
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??
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??
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??
Data Dictionary
Variable
Data Type
Form
User for
double
Form1
Main form
+ delivery
Form 1
Name
totalCost
deliveryCharge
double
Main form
today
staffArray
DateTime
Array of strings
Form1
Main form
time
Form Login
loginCount
integer
Form 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
Unit 59/75??
Login Form
LoginCount = loginCount + 1
If (loginCount == 3)
Inform user 3 chances are up
Exit
EndIf
Ronan Cunningham
Page 11
Unit 59/75??
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??
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
Ronan Cunningham
Page 13
Unit 59/75??
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??
Task 4
Test
Data to be entered
Expected Result
Actual Result
Number
1
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
19.30
19.30
10
11
10.30
14.70
12.70
17.10
12
13.40
15.80
13
14
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
9.50
9.50
23
10.50
10.50
24
11.50
11.50
25
11.40
11.40
26
13.40
13.40
27
15.40
15.40
28
11.40
11.40
Ronan Cunningham
Page 15
Unit 59/75??
29
13.40
13.40
30
15.40
15.40
31
11.40
11.40
32
13.40
13.40
33
15.40
15.40
34
13.80
13.80
35
15.80
15.80
36
17.80
17.80
37
13.80
13.80
36
17.80
17.80
38
15.80
15.80
39
17.80
17.80
40
11.90
11.90
41
12.90
12.90
42
13.90
13.90
42
13.80
13.80
43
15.80
15.80
44
17.80
17.80
45
12.40
12.40
46
14.40
14.40
47
16.40
16.40
48
12.45
12.45
49
14.45
14.45
50
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??
}
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)
{
Page 17
Unit 59/75??
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
Page 19