Exam Fall 2014 Proposed Solution Jan Pettersen Nytun

  • Slides: 13
Download presentation
Exam Fall 2014 Proposed Solution Jan Pettersen Nytun - Ui. A 1

Exam Fall 2014 Proposed Solution Jan Pettersen Nytun - Ui. A 1

Task 1 – Meeting The following class diagram is given: Person - name :

Task 1 – Meeting The following class diagram is given: Person - name : String - participant * * - take. Part. In Meeting - meeting. Name : String 1 - leader + add. Participant(p : Person) : void + get. Leader() : Person - meeting. To. Lead * Jan Pettersen Nytun - Ui. A 2

Person - participant * - name : String * - take. Part. In Meeting

Person - participant * - name : String * - take. Part. In Meeting - meeting. Name : String 1 - leader + add. Participant(p : Person) : void + get. Leader() : Person - meeting. To. Lead * 1 a) Propose Java code that correspond to the class diagram. public class Person{ private String name; private Meeting take. Part. In[]; private Meeting meeting. To. Lead[]; } Jan Pettersen Nytun - Ui. A public class Meeting{ private String meeting. Name; private Person participant[]; private Person leader; public void add. Participant(Person p){} public Person get. Leader(){} } 3

Person - participant * * - take. Part. In - name : String Meeting

Person - participant * * - take. Part. In - name : String Meeting - meeting. Name : String 1 - leader + add. Participant(p : Person) : void + get. Leader() : Person - meeting. To. Lead * 1 b – ) Propose an object diagram that conforms to the class diagram above – it should contain information about 2 meetings named: Meeting. A and Meeting. B. Meeting. A has participants named: Person 1, Person 2. Meeting. B has participants named: Person 2 (same as Person 2 participating in Meeting. A), Person 3, Person 4. A person named Leader is leader of both meetings. : Person : participant : take. Part. In name=“Person 1” : Person name=“Person 2” : Person : take. Part. In : participant : Person name=“Person 4” : take. Part. In name=“Person 3” : participant -meeting. Name = “Meeting. A” : meeting. To. Lead : participant : Meeting -meeting. Name = “Meeting. B” : meeting. To. Lead : leader Leader : Person : leader Jan Pettersen Nytun Ui. A name = -“Leader” 4

c) Propose an XML document that in some way contains the information of the

c) Propose an XML document that in some way contains the information of the object diagram above. : Person : participant : take. Part. In name=“Person 1” : Person name=“Person 2” : Person name=“Person 4” -meeting. Name = “Meeting. A” : participant : meeting. To. Lead : take. Part. In : participant : take. Part. In name=“Person 3” : Person : take. Part. In : participant : Meeting : take. Part. In : Meeting -meeting. Name = “Meeting. B” : participant : meeting. To. Lead : leader Leader : Person name = “Leader” <? xml version="1. 0" encoding="UTF-8"? > <meetingsystem> <meetingname = “Meeting. A“ leader = “Leader”> <participant name = “Person 1“ /> <participant name = “Person 2“ /> </meeting> <meetingname = “Meeting. B“ leader = “Leader” ”> <participant name = “Person 2“ /> <participant name = “Person 3“ /> <participant name = “Person 4“ /> </meeting> <person name=“Person 1“ /> <person name=“Person 2“ /> <person name=“Person 3“ /> <person name=“Person 4“ /> <person name=“Leader“ /> </meetingsystem> 5

d) Do the same as above (i. e. , point c), but instead of

d) Do the same as above (i. e. , point c), but instead of an XML document, show the content in the form of tables as you find them in relational databases (show table names, column names and data). : Person : participant : take. Part. In name=“Person 1” : Person name=“Person 2” : Person name=“Person 4” Table: Person Name Person 1 Person 2 Person 3 Person 4 Leader -meeting. Name = “Meeting. A” : participant : meeting. To. Lead : take. Part. In : participant : take. Part. In name=“Person 3” : Person : take. Part. In : participant : Meeting : take. Part. In : Meeting -meeting. Name = “Meeting. B” : leader : meeting. To. Lead : participant : leader Table: Participation Meeting. Name Person. Name Meeting. A Person 1 Meeting. A Person 2 Meeting. B Person 3 Meeting. B Person 4 Leader : Person name = “Leader” Table: Meeting. Name Leader Meeting. A Leader Meeting. B Leader 6

Person - participant * - name : String 1 - leader * - take.

Person - participant * - name : String 1 - leader * - take. Part. In Meeting - meeting. Name : String + add. Participant(p : Person) : void + get. Leader() : Person - meeting. To. Lead * e) Write an OCL constraint that states that: The number of participants (see role participant in figure) to a meeting must be at least 2. context Meeting inv: participant->size() > = 2 f) Write an OCL constraint that states that: The person given as leader of a meeting cannot also be participant to that same meeting. context Meeting inv: participant->excludes(leader) Jan Pettersen Nytun - Ui. A 7

Task 2 – Registration of work activities Make and state your own assumptions if

Task 2 – Registration of work activities Make and state your own assumptions if you find it necessary. Teachers working at a highly rated university in the south of Norway need to have work plans to know what is expected from them in their jobs and you are to start modelling a system for handling this. Work planes are stored for all employees, for the current year and the years an employee has been employed. The following is an example of stored information in the system, i. e. , the work plan for Kari Norman, which works at the ICT institute which is part of Faculty of Engineering and Science. The work plan is for year 2014, when Kari Norman is holding a 90% employment position (a full position is recorded as 100%). Her Social Security Number (SSN) is 12036744501. Year: 2014 Time Budget Employee: Kari Norman SSN: 12036744501 Position: 90% Faculty: Faculty of Engineering and Science Institute: ICT Category Teaching R&D Diverse Sum Total 1304 152 63 1519 Allocated 879 422 108 1409 Difference 425 -270 -45 110 There are 3 categories of work: Teaching, R&D (Research & Development) and Diverse. Category Diverse is meant to cover all that is not covered by the two other categories. We assume that a full time position amounts to 1687 work hours a year, a 90% position will then amount to 1519 (when rounded down); this number can be seen as sum of the Total column in the table above. As can also be seen above, the total amount of hours has been shared between the 3 categories, e. g. , R&D is given 152 hours (see column Total). How the numbers of the Total column comes about does not concern your task (however, it is just some policy decided by the leaders, e. g. , like having a policy that R&D should be 10% of the total). The column called Allocated shows hours allocated to specific projects of the categories, e. g. , 879 hours has been allocated to teaching projects; the specific projects are not shown here (they will be discussed later, but should be ignored when solving point (a) below). The column called Difference shows the mismatch between total and allocated, e. g. , there are 425 hours of teaching not allocated and there are 270 hours “too many” allocated to R&D.

(a) Propose a class diagram capturing the information given above. There should be at

(a) Propose a class diagram capturing the information given above. There should be at least 3 classes. Ignore operations. Employee name : String s. SN: String 1 * Work. Plan year: int position : int * Institute 1 name : String * 1 Faculty name : String Assuming an employee must be registered once for each institute he works at. has. Category 1 part. Of * Category name : String Total : int allocated : int /difference: int difference is derived: difference = total-allocated Jan Pettersen Nytun - Ui. A One could take another approach and Subclassed Category into Teaching. Category, etc. 9

(b) Propose an object diagram that conforms to your class diagram defined in point

(b) Propose an object diagram that conforms to your class diagram defined in point (a). Let the object diagram contain the information given above (i. e. , information about Kari Norman, etc. ) : Employee Name = “kari Norman” s. SN = 12036744501 : Institute name = “ICT” : Faculty name = “Faculty of Engineering and Science” : Category name = “Teaching” total = 1304 allocated = 879 : Work. Plan Year = 2014 Position = 90 : Category name = “R&D” total = 152 allocated = -270 : Category name = “Diverse” total = 63 allocated = 108 Jan Pettersen Nytun - Ui. A 10

A work plan will contain more information than given above; for each category specific

A work plan will contain more information than given above; for each category specific projects will be described. Examples of information stored are given below: Teaching Project IKT 413 Kari IKT 411 Kari … Sum Description Lecture Supervision … R&D Allocated 174 422 … 879 Project Nurse Terminology How real is M 0? … Sum Description Make app Write article … Allocated 100 50 … 422 Diverse Project Monday Meetings PHD Committee … Sum Description Lunch meetings PHD of Ola … Allocated 20 40 … 108 A project will belong to exactly one of the earlier mentioned categories (Teaching, R&D or Diverse) and to one employee. It will have a unique name, a description and a number of allocated hours. A teaching project will always be related to one course. A course has among other things an id, name and a number of study points. Several teachers may have teaching projects related to the same course. Jan Pettersen Nytun - Ui. A 11

(c) Extend (or change) your class diagram from point (a) to include the information

(c) Extend (or change) your class diagram from point (a) to include the information above. Ignore operations. * Work. Plan year: int position : int 1 has. Category 1 part. Of * Employee name : String s. SN: String Category name : String Total : int allocated : int belongs. To 1 Project * name : String description: String allocated : int Teaching. Project * RAnd. DProject Diverse. Project 1 Course code : String name : String sp : int year : int One may have the description (i. e. , code, name, sp) of the course in one separate class like Course. Description and associate Course to this class (Course having year as attribute). 12

(d) Typically a course is allocated 30 hours per study point. Make a high

(d) Typically a course is allocated 30 hours per study point. Make a high level activity diagram describing a process of finding and printing the courses that have allocated more hours than this. E. g. , a 5 study point course should typically have allocated 150 hours (5 X 30), if more hours than this, then it should be found. “High level activity diagram” implies that you should not use swim lanes when making the activity diagram. Find first course [no course found] [course found] Find first project connected to course Find next course [else] Print: Course Name, study points and allocated hours [Hours>sp*30] Hours = 0 [no project found] [project found] Hours = Hours + allocated hours Find next project connected to course 13