Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Level Three
_________________________________________________________________
Object Oriented Software Development COMP1307
Page 1 of 10
APPROVED
c. Discuss what the key elements of a class that follows the canonical
form should look like and provide outline code for each requirement.
Outline code should include method names etc. but not method
content.
[15 marks]
2. You have been asked to design a website for a new style of on-line coffee
shop. Instead of forming a queue at the counter to order your coffee, waiting
for your order and then sitting down at a table, the new website will allow
customers to order and pay directly from their table. The screen (provided at
each table) will allow customers to choose the type of coffee they want, cakes
etc. and then place an order and pay on-line with a card. The coffee and cakes
will then be delivered to the table when they are ready.
a. The system you have been asked to design is for a small coffee shop
using a combination of JSP and servlet technologies as appropriate.
You have been asked to write a brief report stating why you would
choose to use each and give examples related to the above scenario of
what parts of the system you would choose to use JSPs for and what
parts you would choose to use servlets for.
[13 marks]
b. Outline the Struts framework and discuss whether you would choose to
use it in the coffee shop scenario given above.
[12 marks]
__________________________________________________________________
Object Oriented Software Development COMP1307
Page 2 of 10
APPROVED
b. On further inspection you realise that their system would run much
faster if they used threads. Extend your notes for the presentation to
include an explanation of the advantage and disadvantages of using
threads.
[6 marks]
__________________________________________________________________
Object Oriented Software Development COMP1307
Page 3 of 10
APPROVED
Consider the code below which a student has written to extract and output data
from the database:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import sun.jdbc.odbc.*;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
__________________________________________________________________
Object Oriented Software Development COMP1307
Page 4 of 10
APPROVED
Question 4 continued
Connection con = DriverManager.getConnection
("jdbc:odbc:Driver={Microsoft AccessDriver(*.mdb)};DBQ=Example.mdb");
while (rs.next())
{
String name = rs.getString("name");
int seat = rs.getInt("seat");
inputTextArea.append(
name + " " + seat + "\n");
}
stmt.close();
con.close();
}
catch (Exception e)
{
System.err.println(e);
System.exit(1);
}
}
}
a. Explain what this program does when loaded, and sketch a diagram to show
the form of the GUI with the expected output. You do NOT have to explain
every line – just explain the main functionality, including the purpose of the
methods.
[10 marks]
b. A system using many such Frame classes as the one defined above will
contain many code segments with dummy implementations of unused Frame
methods, as in the code above. Explain how these duplicate code segments can
be eliminated by refactoring, with a suitable code example.
[5 marks]
__________________________________________________________________
Object Oriented Software Development COMP1307
Page 5 of 10
APPROVED
Question 4 continued
[5 marks]
[5 marks]
_________________________________________________________________
Object Oriented Software Development COMP1307
Page 6 of 10
APPROVED
b. Describe the main characteristics of the Sets, Lists and Maps collection
types.
[6 marks]
import java.util.*;
set.add("a");
set.add("b");
set.add("c");
set.remove("c");
int size = set.size();
System.out.println("size = " + size);
set.add("a");
size = set.size();
System.out.println("size = " + size);
boolean b = set.contains("a");
System.out.println("b = " + b);
b = set.contains("c");
System.out.println("b = " + b);
Iterator it = set.iterator();
while (it.hasNext())
{
Object element = it.next();
System.out.println(element);
}
}
}
__________________________________________________________________
Object Oriented Software Development COMP1307
Page 7 of 10
APPROVED
Question 5 continues
_________________________________________________________________
Object Oriented Software Development COMP1307
Page 8 of 10
APPROVED
__________________________________________________________________
Object Oriented Software Development COMP1307
Page 9 of 10
APPROVED
Question 6 continues
[3 marks]
iii. State what the intent of this pattern is, and when such a pattern
should be used.
[5 marks]
_________________________________________________________________
Object Oriented Software Development COMP1307
Page 10 of 10