You are on page 1of 10

ab1

UNIVERSITY OF BOLTON DEPARTMENT OF BUILT ENVIRONMENT AND ENGINEERING ELECTRONICS PATHWAY SEMESTER 1 EXAMINATION 2009/2010 SOFTWARE ENGINEERING MODULE NO: ECE3044

Date: Wednesday, 20 January 2010

Time:

10.00 a.m. 12.00 noon

INSTRUCTIONS TO CANDIDATES:

There are 5 questions. Answer 4 questions. All questions carry equal marks. Individual marks are shown within the question.

Page 2 of 10

Built Environment and Engineering Electronics Pathway Semester 1 Examination 2009/2010 Software Engineering Module No. ECE3044 Question 1 Refers to code in Appendix 1 a) Explain the sequence diagram below which shows the objects involved for event handling in Java? (6 marks)

b) c) d)

Consider the program code in Appendix 1.1 for a simple GUI. Sketch the graphical output for this program? (9 marks) Explain how code in Appendix 1.2 makes the GUI interactive? (3 marks)

For all the possible user interactions what are the responses of the program? (7 marks) Total 25 marks

Question 2 Refers to code in Appendix 2 a) What are design patterns and why are they important for software development (4 marks) How are design patterns classified? What is the standard style for presenting a catalogue entry? (6 marks) Describe the Singleton design pattern and its applications. (3 marks)

b) c)

Question 2 continued overleaf

Page 3 of 10

Built Environment and Engineering Electronics Pathway Semester 1 Examination 2009/2010 Software Engineering Module No. ECE3044 Question 2 continued

d) e)

Appendix 2 contains the Java code for a Singleton class. How does this code work? (4 marks) Draw a class diagram for the Java GUI component hierarchy and discuss its structure. What design pattern was inspired by the GUI component hierarchy? Draw

a class diagram of this pattern and explain how it can be used to model a part-whole hierarchy of objects. (8 marks) Question 3 Refers to code in Appendix 3 a) What is the function of the methods init(), start(), stop(), destroy(), run() and paint() of a Java applet? (3 marks) b) What is the purpose of a software idiom, using an animation idiom to illustrate your answer? (4 marks)

c)
d)

Explain how the code in Appendix 3 for the animation idiom operates?

(10 marks)

A bouncing ball applet employing the animation idiom tends to flicker. Why does this flickering occur? (2 marks) How can the technique of double buffering be employed to reduce flickering? (3 marks) How can Java applet animation be used (i) to enhance an advertisement on a commercial web site and (ii) to illustrate a concept in science/engineering?

e)

f)

(3 marks)

Total 25 marks

Please turn the page

Page 4 of 10

Built Environment and Engineering Electronics Pathway Semester 1 Examination 2009/2010 Software Engineering Module No. ECE3044 Question 4 Refers to Appendix 4 a) Using the example of the organisation of a University, explain the concepts of aggregation and composition. Provide a class diagram. (6 marks) Appendix 4 shows a circuit diagram for a half adder logic circuit. What is the truth table for this circuit? (2 marks) Produce a UML class diagram for the half adder circuit showing the part (gates) whole (complete half adder circuit) relationship? (4 marks) Using the Java classes for the primitive gates AND, OR and NOT in Appendix 4 develop Java code for a half adder class. The inputs (A,B) and outputs (Sum, Carry) should be member data. The method calc(int Ain, int Bin) calculates the output of the half adder gate for input parameters (Ain, Bin) (8 marks) How can the half adder class just developed be tested? Show the code for testing this class. (5 marks) Total 25 marks Question 5 Refers to Appendix 5 a) Show how a sequence diagram can be employed to depict the time ordering of method invocations for printing a document using a word processor. (5 marks) With the assistance of your personal experience of purchasing tickets over the Internet for the theatre, explain the meaning of the Use Case diagram in Appendix 5.1 for theatre operations. (8 marks) With the assistance of your personal experience of how a theatre is organised, identify, categorise and discuss the relationships captured by the conceptual class model, for the theatre booking system in Appendix 5.2. (12 marks) Total 25 marks

b)

c)

d)

e)

b)

c)

END OF QUESTIONS

Page 5 of 10

Built Environment and Engineering Electronics Pathway Semester 1 Examination 2009/2010 Software Engineering Module No. ECE3044 Appendix 1

Appendix 1.1
public class NestedPanelsSimple extends Applet { protected protected protected protected Label messageBar; Choice choice; int nButtons = 9; Button [] buttons = new Button [nButtons];

public NestedPanels () { Panel center = new Panel(); center.setLayout(new BorderLayout()); center.add(buttons[0] BorderLayout.NORTH); center.add(buttons[1] BorderLayout.SOUTH); center.add(buttons[2] center.add(buttons[3] center.add(buttons[4] BorderLayout.CENTER); = new Button("north"), = new Button("south"), = new Button("west"), BorderLayout.WEST); = new Button("east"), BorderLayout.EAST); = new Button("center"),

Panel south = new Panel(); south.setLayout(new FlowLayout()); south.add(buttons[5] = new Button("Help")); choice = new Choice(); choice.addItem("one"); choice.addItem("two"); choice.addItem("three"); choice.addItem("four"); choice.addItem("five"); south.add(choice); messageBar = new Label("This is a message bar."); south.add(messageBar); setLayout(new BorderLayout()); add(buttons[6] = new Button("North"), BorderLayout.NORTH); add(buttons[7] = new Button("West"), BorderLayout.WEST); add(buttons[8] = new Button("East"), BorderLayout.EAST); add(south, BorderLayout.SOUTH); add(center, BorderLayout.CENTER); } }

Page 6 of 10

Built Environment and Engineering Electronics Pathway Semester 1 Examination 2009/2010 Software Engineering Module No. ECE3044

Appendix 1.2
import java.awt.*; import java.awt.event.*; public class NestedPanels2Simple extends NestedPanelsSimple implements ActionListener, ItemListener { public NestedPanels2Simple() { // create all the components super(); // register item listener choice.addItemListener(this); // register action listener registerButtonHandler(); } public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { messageBar.setText("Choice selected: " + event.getItem()); } } public void actionPerformed(ActionEvent event) { Button source = (Button) event.getSource(); messageBar.setText("Button pushed: " + source.getLabel()); } protected void registerButtonHandler() { for (int i = 0;i < nButtons; i++) { buttons[i].addActionListener(this); } } }

Page 7 of 10

Built Environment and Engineering Electronics Pathway Semester 1 Examination 2009/2010 Software Engineering Module No. ECE3044 Appendix 2

Code Snippet for the Singleton Design Pattern


public class Singleton { private static Singleton theInstance = new Singleton(); private Singleton() { //initialize instance fields } public static Singleton getInstance() { return theInstance; } //other fields and methods }

Appendix 3

Code Snippet for the Animation Idiom


public class AnimationApplet extends java.applet.Applet implements Runnable { Thread mainThread = null; int delay; public void start() { if (mainThread == null) { mainThread = new Thread(this); mainThread.start(); } } public void stop() { mainThread = null; } public void run(){ while (Thread.currentThread() == mainThread) { repaint(); try{ Thread.currentThread().sleep(delay); } catch(InterruptedExceptione){} } } public void paint(java.awt.Graphics g) { <paint the current frame> } <other methods and fields> }

Page 8 of 10

Built Environment and Engineering Electronics Pathway Semester 1 Examination 2009/2010 Software Engineering Module No. ECE3044 Appendix 4 The Circuit Diagram for a Half Adder Circuit

OR

AND

AND

NOT

The Java Code for AND, OR and NOT Gates


public class AndGate { public int generateOutput(int input1, int input2) { int output; if(input1 == 1 && input2 == 1) { output = 1; } else { output = 0; } return output; } } public class OrGate { public int generateOutput(int input1, int input2) { int output; if(input1 == 1 || input2 == 1) { output = 1; } else { output = 0; } return output; } }

Page 9 of 10

Built Environment and Engineering Electronics Pathway Semester 1 Examination 2009/2010 Software Engineering Module No. ECE3044
public class NotGate { public int generateOutput(int input1) { int output; if(input1 == 1) { output = 0; } else { output = 1; } return output; } }

Appendix 5 5.1 The Use Case Diagram for Theatre Operations

Page 10 of 10

Built Environment and Engineering Electronics Pathway Semester 1 Examination 2009/2010 Software Engineering Module No. ECE3044 5.2 The Class Diagram for a Theatre Booking System

You might also like