2D1385 Programutvecklingsteknik

Prutt-07

2007-09-14

Take Home Exam (omtentamen)

NOTES: (Please read these carefully!)

(i) Clearly mark at the top of each sheet you use: (a) your name, (b) the page number.

(ii) On the front page indicate (a) how many pages are contained in your work in total. Clearly mark: (b) your name (c) your personnummer, (d) your e-mail address (in case I need to contact you)

(iii) There are two ways to submit your work. (a) Your work may be handed in to NADA's studentexpedition no later than Monday 17th September 2007 at 15.00 pm (closing time). After this time it will be marked as late, and marks will be subtracted pro-rata. (b) If for any reason your are unable to reach the studentexpedition yourself (for example if you are at work) then you may post your manuscript to: Studentexpeditionen, NADA, KTH, 100 44 Stockholm. The date and time on the postmark will be taken as the date and time of your submission. The same deadline applies to manuscripts submitted by post.

(iv) If manuscripts are submitted in any other place or by any other means than those described in Part (iii) then the examiner and NADA cannot be held responsible in the case that manuscripts are lost.

(v) If you have any questions about the exam (for example, if you do not understand a question) you may call my mobile number 076 223 86 79. Please do not call before 11.00 am or after 17.00pm!

(vi) You may use your kursbunt, and any course books. You are allowed to use the internet including search engines. However, any work which you download and use must be credited to its source. You are not allowed to discuss or develop your answer with anyone else before all manuscripts have been handed in. You are not allowed to copy anyone else's work. By handing in your manuscript you are declaring that you have abided by these rules. In the case that cheating is suspected, actions will be taken against all students involved.

(vii) Write clearly. No marks will be awarded for work that I cannot read. You can write your answers in swedish or in english.


Answer all questions. Maximum marks are 50 points. A grade 3 will be awarded for 25 points or more, grade 4 is awarded for 30 points or more, grade 5 is awarded for 35 points or more.

Question 1 (Total 32 points). Read this whole question before you begin to answer!

Consider the following informal requirements description for a vehicle simulation program.

A vehicle may either be a land vehicle or a marine vehicle. Amphibious craft are both land and marine vehicles. Every vehicle has one or more engines, where an engine may either use diesel or petrol as fuel. A land vehicle may use petrol or diesel as fuel, while a marine vehicle must use diesel (for fire safety). An engine has a maximum power measured in watts and a current revolution speed, measured in revolutions per second.

Every marine vehicle has one or more propellors, while a land vehicle has two or more wheels. One engine powers one or more propellors and one or more wheels.

Trucks, motorbikes, cars and locomotives are special types of land vehicle.

A motorbike has two or three wheels. A truck and a car have at least four wheels, while a locomotive has at least six wheels. On a car and a truck, one engine powers two or more wheels. On a locomotive, one engine powers four or more wheels. One wheel is always connected to at most one other wheel on any land vehicle.

A car has a current gear value, which is an integer between 1 and 5. A car also has a speed function which given a current gear value and a current revolution speed (of an engine), returns the velocity (in Km per second) of the car.

(i) (10 points) Rearrange the above information into a data dictionary consisting of nouns, verbs and relational phrases. Your data dictionary must satisfy the following requirements: (a) Your dictionary entries under each category must be alphabetically ordered, (b) it is not necessary to define a word unless you think its meaning is unclear from the text, (c) every entry in your data dictionary must be used somewhere in your class diagram for part (ii) below, (d) every entity used in your class diagram for part (ii) below must appear somewhere in your data dictionary.

(ii) (14 points) Using your answer to part (i), arrange all these nouns, verbs and relations into a UML class diagram. By using additional classes where necessary and inheritance, carefully avoid repeating the same attributes or methods within several classes. Be careful to include multiplicity and logical information (including asymmetry) on relations, as well as dependencies between classes, where these can be clearly identified.

(iii) (2 points) Using any classes you need from your diagram for part (ii), draw a new class diagram to model the requirements that: (a) a wheel is connected to a different wheel (i.e. not to itself, we imagine that an axle connects the two), and (b) if wheel object A is connected to wheel object B then also B is connected to A.

(iv) (3 points) Using any classes you need from your diagram for part (ii), draw a new class diagram to show how UML can model the requirement that an engine powers some wheels or propellors, but wheels and propellors do not power engines (asymmetry). Give two other ways to model this kind of requirement in the UML language.

(v) (3 points) Draw a UML object diagram that instantiates your class diagram for part (i), and which contains at least 2 cars in different gears.

Question 2. (Total 8 points) Your company decides that it needs a hardware and platform independent implementation of the vehicle simulation program. However, your company decides not to use the Java programming language for security reasons. (It is very easy to reverse compile Java byte code to the original source code.)

(i) (4 points) What high-level software architecture would help in solving this problem? Explain how it would help, preferably with the use of an architectural diagram.

(i) (4 points) What advantages and disadvantages would this architecture have from your company's managerial and developer's point of view?

Question 3 (Total 10 points).

(i) (8 points) Write a DTD that is suitable for defining XML files that represent vehicle simulations based on your UML class diagram for Question 1.(i). You should use as much DTD/XML validation as possible based on the constraints given in your original class diagram.

(ii) (2 points) Write a short XML file that correctly instantiates your DTD to part (i) and which accurately models your vehicle object diagram that you gave in your answer to Question 1 part (v).