Assignment 1: Sample Answers CompSci 230 S1 2013

Assignment 1: Sample Answers
CompSci 230 S1 2013
Clark Thomborson
Version 1.1, 27 March 2013
Total marks on this assignment: 30. This assignment counts 3% of total marks.
Submission deadline: 4pm, Friday 22 March. Late submissions will be accepted but heavily penalised, as noted in
Slide 7 of the Course Information. Only your last submission will be marked. The lateness penalty is
•
•
10% of possible marks, for late submissions prior to 4pm Monday 25 March, and
50% of possible marks, for later submissions prior to 4pm Wednesday 27 March.
Submit: one file (as a zip archive) to the Cecil dropbox. See Slide 11 of the Course Information. Your zipfile should
contain one document (in PDF, DOC, DOCX, or ODF) with all of your diagrams and textual answers, and one jarfile
with all of your code.
Questions to be answered.
1. (10 marks) Immediately below these questions, you will find an informal specification of a software system
called QuizWhiz. Your first task, after reading this document, is to develop a set of use cases for the QuizWhiz
system. Your use cases should be well-named (1 mark), and they should cover the major functional requirements
on this system (3 marks) without any excessive detail (1 mark). You should submit, for marking, a use case
diagram, and a brief textual description of each of the use cases in your diagram. Your descriptions should be in
the (semi-formal) format illustrated at the bottom of slide 15 of the lecture slides on Use Cases, so that there are
four subsections in each use-case description containing brief but informative answers to the following questions.
a. Who uses this case, and what task does this user accomplish if the case is successfully completed? (2
marks)
b. What is the main flow of events in a successful execution of this case? (2 marks)
c. Who are the related actors (if any), and what are the related use cases (if any)? (1 mark)
d. Are there any special conditions on this case, and if so, what extension use case would be invoked under
these conditions? (1 bonus mark for any valid extension case 1). Note: a bonus mark will offset a mark
that is deducted elsewhere in this question, but it will not raise your marks on this question above 10.
Sample Answer to Q1
My diagram (on the next page) shows four primary use-cases.
1. “Create Quiz” is used by an Instructor who wants to create a new quiz for an existing course in Cecil. The
main flow of events:
a. In QM: login
b. In QM: create the text of a new quiz
c. In QM: logout
d. In Cecil: associate the new quiz with the existing course, and set the assessment parameters (e.g.
how many times the student can attempt the quiz)
1
I don’t expect any CompSci 230 student to define extension points in their use case analyses – this is an advanced topic, and is
not examinable. However if you care to do some extra reading to discover what an “extension case” is, and if you can find some
valid application for this concept in this problem, go for it!
Related actors: none. Related use cases: includes 3 cases from QM and 1 case from Cecil (as indicated in the
staps); not included in any other case.
Special conditions (for a bonus mark): if the instructor is already logged in to QM, then their existing login
session should be reused (as an alternative to the QM-login flowstep). If the instructor indicates that they
wish to remain logged in to QM, then the QM-logout flowstep should be omitted.
2.
“Get Marksheet” is used by a Student to obtain a report on their marks for a quiz. Main flow:
a. Retrieve a marksheet from a storage area in QuizWhiz. (Note: this is a minimalistic design. A more
detailed design would have a first step of looking up, in a Cecil gradebook, the student’s marks in a
course; the Cecil gradebook must have a reference to the desired marksheet. However I decided
against attempting to simulate a Cecil gradebook at that level of detail.)
Related actors: Instructor. Related use cases: no inclusions; included in “Get Marksheets”.
Special conditions: none.
3. “Get Marksheets” is used by an Instructor who wants a summary report on all of the marksheets associated
with a quiz.
a. Retrieve a list of marksheets associated with a quiz
b. For each marksheet on the list, retrieve the marksheet and summarise its contents.
Related actors: none. Related use cases: includes “Get Marksheet”; not included in any other case.
Special conditions: none.
4. “Sit Quiz” is used by a student who wants to attempt a quiz. Main flow of events:
a. In QM: login
b. In QM: sit the quiz, get a score
c. In QM: logout
d. In QuizWhiz: update the student’s marksheet to include the new score
Related actors: none. Related use cases: includes 3 cases from QM and 1 case from Cecil (as indicated in the
staps); not included in any other case.
Special conditions: if the student has attempted the quiz too many times already, then they should not be
allowed to sit the quiz again. If the QM session times out during a quiz-sitting, there should be a way for the
student to “restart” their sitting (unless they exceed the maximum time-limit, set by the instructor when the
quiz is created).
Marking notes. Students need not produce exactly this list of primary use-cases – they might show the tasks
of quiz-creation, quiz-sitting, and report-writing at a slightly lower level of detail, and they might have a
single “Report on Scores” use-case for use by both Students and Instructors. They should not show much
detail in Cecil or QM: in particular, they need not show the QM login/logout inclusions of my design. Then
again, they might show a bit more detail. Deduct 1 mark for “excessive detail” if any case has more than five
<<includes>>, or if more than 15 cases are shown.
2. (10 marks) Perform an OO analysis. Submit a class diagram showing the most important high-level classes in
your OO design for this system, with appropriate names for your classes (1 marks), well-named and important
attributes (2 marks), well-named and important methods (3 marks), with well-chosen relationships (e.g.
aggregation, composition, generalization) of appropriate multiplicity between your classes (3 marks). Do not
include any “low level” classes, unimportant attributes, or unimportant methods (1 mark).
Sample Answer to Q2
Marking notes. Students should be producing a wide variety of class diagrams – because this is quite an openended design problem. In particular: they need not have a separate object for a Scoresheet – this might be part
of the Marksheet. They need not objectify the SummaryStatistic, as in my diagram. The two marks for “wellnamed and important attributes” should be awarded if they show at least one instance attribute of a Quiz (or
similarly-named class) which would record the quiz-marking policy (maxAttempts, summariseScores in my
diagram), and at least one instance attribute of an object which records the scores obtained by a student on a
quiz. The three marks for “well-named and important methods” should be awarded if the student’s diagram
makes it clear which class (or classes) would be handling the quiz-creation, score-reporting, and quiz-sitting
tasks.
3. (5 marks) Develop a skeleton implementation (3 marks) of every class in your OO design, with empty or nearlyempty methods returning nominal values (such as 0, or an empty String), in your Java development environment.
Add as little “meat” as possible (1 mark) to the bones of your skeleton, until you have a barely-functional
prototype of the desired system with the behaviour described at the end of this assignment (1 mark). Submit a
jarfile of your prototype.
Marking notes. Regrettably, my assignment handout did not make it clear whether the students should be
submitting a jarfile (with .java source) or an executable jarfile (with .class files). So we must accept either one,
for full marks.
If the student submits an executable jarfile, then you should execute it, to confirm that it produces the required
output. Trivially, this might be a main() with two println() statements, so you should examine the contents of
the jarfile briefly. It should contain one classfile for each of the classes in the student’s diagram. You won’t have
time to decompile their classfiles, but at least three of them should contain more than 1 kb (3 marks).
If the student submits a jarfile, then you should not attempt to compile & execute it. Instead, you should inspect
it to discover whether the main() is in the same class as indicated in their class diagram (1 mark), and whether
the main() is not merely printing the required output – but is, instead, instantiating some actors (presumably a
Student and an Instructor) and invoking a method that is documented in their class diagram (1 mark). You
should also inspect one of the methods which should be involved in the quiz-reporting use-case (according to
your analysis of their class diagram) to see if it is doing something useful.
4. (5 marks) Examine the code of your prototype, to determine its instantiation behaviour. Create an object
diagram which shows all of the instantiations (3 marks) of all classes in your OO design of question 2. Your
diagram should also include the class instance, in the style of slide 17 of the Introduction to OO Design (although
you need not use the same colour-scheme). Submit your object diagram, after marking it up with integers in the
range 0..20 to indicate the order in which these instantiations occur. All of the class instances should be marked
with the integer “0”, to indicate that these instantiations occur before the first user-defined object is instantiated
(and this object should be marked with a “1” in your diagram). 2
Sample Answer to Q4
On the next page you’ll find a partial answer, showing all of the object instances but only three of the realisations of
the class objects. The QuizWhizTestApp object has some local variables which are very important to this application,
for these variables (s1, i1, c1, and qw1) are used to reference the instantiations (at times 1, 2, 3, and 4, respectively)
of a Student, Instructor, Course, and Quiz. These instantiations must occur after the corresponding classes are
loaded (at time 0), but the loaded class objects are unimportant because they have no static variables. Accordingly I
2
You may use the UML-standard “note symbol” for your markups, but this is not required.
have omitted the other class objects from my diagram, to keep the focus on the important instantiations. I used the
<<instanceOf>> stereotype on the association between an instantiated object and its class, as in Figure 7.8 of the
OMG UML Infrastructure v2.4.1.
Marking Notes. Regrettably, the assignment didn’t indicate how all five marks would be awarded. Award 3 marks if
the student’s diagram shows instantiations of a Student object, an Instructor object, and a Quiz object. Award 1
mark if it shows at least one class instance. Award 1 mark if an instantiation order is shown, and is not obviously
incorrect: the classes should be instantiated at load-time (0), and the objects are created sequentially (1, 2, 3, …).
As noted in slide #19 of my lecture slides on Introduction to OO Design, I do not expect students to produce an
object diagram that is fully conformant with any version of the OMG UML specification. In particular, the use of the
<<instanceOf>> stereotype is entirely optional, as is the navigability of this association. An improper use of colons in
the titles of these instances should not be penalised. (In case anyone is curious: the object instances are anonymous
but typed by their class, whereas the class instances are named (with their class name) but of type Class. So I might
have written “Student :Class” instead of “Student” in the title field of the instance specification at the top right
corner.)
5. (2 bonus marks). The informal specification of QuizWhiz is incomplete. To complete this assignment, you will
have to fill in some details by making some assumptions about “what Team Cecil really wants”, “how Cecil is
actually implemented”, and “what functions are provided by QM”. If you find yourself making such assumptions,
and if they are important to your design, then you should briefly discuss them in your submission.
Marking notes. Award up to 2 bonus marks, if a student clearly describes an important assumption they made while
completing this assignment. The maximum possible on this assignment remains 30, so the bonus marks are only
counted if the student misses marks elsewhere on this assignment.