Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exam Fall 2014 Proposed Solution

Similar presentations


Presentation on theme: "Exam Fall 2014 Proposed Solution"— Presentation transcript:

1 Exam Fall 2014 Proposed Solution
Jan Pettersen Nytun Jan Pettersen Nytun - UiA

2 Jan Pettersen Nytun - UiA
Task 1 – Meeting The following class diagram is given: - participant Person * Meeting * - takePartIn - name : String - meetingName : String 1 - leader + addParticipant(p : Person) : void + getLeader() : Person - meetingToLead * Jan Pettersen Nytun - UiA

3 Jan Pettersen Nytun - UiA
- participant Person * Meeting * - takePartIn - name : String - meetingName : String 1 - leader + addParticipant(p : Person) : void + getLeader() : Person - meetingToLead * 1a) Propose Java code that correspond to the class diagram. public class Meeting{ private String meetingName; private Person participant[]; private Person leader; public void addParticipant(Person p){} public Person getLeader(){} } public class Person{ private String name; private Meeting takePartIn[]; private Meeting meetingToLead[]; } Jan Pettersen Nytun - UiA

4 Jan Pettersen Nytun - UiA
- participant Person * Meeting * - takePartIn - name : String - meetingName : String 1 - leader + addParticipant(p : Person) : void + getLeader() : Person - meetingToLead * 1b – ) Propose an object diagram that conforms to the class diagram above – it should contain information about 2 meetings named: MeetingA and MeetingB. MeetingA has participants named: Person1, Person2. MeetingB has participants named: Person2 (same as Person2 participating in MeetingA), Person3, Person4. A person named Leader is leader of both meetings. :participant :Person :takePartIn :Meeting name=“Person1” :takePartIn -meetingName = “MeetingA” :participant :Person :meetingToLead :participant :takePartIn name=“Person2” :Meeting :participant :takePartIn :Person -meetingName = “MeetingB” :takePartIn name=“Person3” :meetingToLead :leader :Person Leader :Person :participant :leader Jan Pettersen Nytun - UiA name=“Person4” name = “Leader”

5 c) Propose an XML document that in some way contains the information of the object diagram above.
:participant :Person :takePartIn name=“Person1” :Meeting :participant :takePartIn -meetingName = “MeetingA” :Person :participant :meetingToLead name=“Person2” :takePartIn :participant :Person :Meeting :takePartIn name=“Person3” -meetingName = “MeetingB” :takePartIn :leader :meetingToLead :Person Leader :Person :participant :leader name=“Person4” name = “Leader” <?xml version="1.0" encoding="UTF-8"?> <meetingsystem> <meeting meetingname = “MeetingA“ leader = “Leader”> <participant name = “Person1“ /> <participant name = “Person2“ /> </meeting> <meeting meetingname = “MeetingB“ leader = “Leader” ”> <participant name = “Person3“ /> <participant name = “Person4“ /> </meeting> <person name=“Person1“ /> <person name=“Person2“ /> <person name=“Person3“ /> <person name=“Person4“ /> <person name=“Leader“ /> </meetingsystem>

6 MeetingName PersonName Name MeetingName Leader
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). :participant :Person :takePartIn name=“Person1” :Meeting :participant :takePartIn -meetingName = “MeetingA” :Person :participant :meetingToLead name=“Person2” :takePartIn :participant :Person :Meeting :takePartIn name=“Person3” -meetingName = “MeetingB” :takePartIn :leader :meetingToLead :Person Leader :Person :participant :leader name=“Person4” name = “Leader” Table: Participation Table: Person Table: Meeting MeetingName PersonName Name MeetingName Leader MeetingA Person1 Person1 MeetingA Leader MeetingA Person2 Person2 MeetingB Leader MeetingB Person2 Person3 MeetingB Person3 Person4 MeetingB Person4 Leader

7 Jan Pettersen Nytun - UiA
- participant Person * Meeting * - takePartIn - name : String - meetingName : String 1 - leader + addParticipant(p : Person) : void + getLeader() : Person - meetingToLead * 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 - UiA

8 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 Year: Time Budget Employee: Kari Norman SSN: Position: 90% Faculty: Faculty of Engineering and Science Institute: ICT Category Total Allocated Difference Teaching 1304 879 425 R&D 152 422 -270 Diverse 63 108 -45 Sum 1519 1409 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 to1519 (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.

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

10 Jan Pettersen Nytun - UiA
(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 :Institute :Faculty Name = “kari Norman” sSN = name = “ICT” name = “Faculty of Engineering and Science” :Category name = “Teaching” total = 1304 allocated = 879 :WorkPlan :Category Year = 2014 Position = 90 name = “R&D” total = 152 allocated = -270 :Category name = “Diverse” total = 63 allocated = 108 Jan Pettersen Nytun - UiA

11 Jan Pettersen Nytun - UiA
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 Description Allocated IKT413 Kari Lecture 174 IKT411 Kari Supervision 422 Sum 879 R&D Project Description Allocated Nurse Terminology Make app 100 How real is M0? Write article 50 Sum 422 Diverse Project Description Allocated Monday Meetings Lunch meetings 20 PHD Committee PHD of Ola 40 Sum 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 - UiA

12 and associate Course to this class (Course having year as attribute).
(c) Extend (or change) your class diagram from point (a) to include the information above. Ignore operations. * 1 hasCategory WorkPlan Category partOf * year: int position : int name : String Total : int allocated : int 1 Employee belongsTo 1 name : String sSN: String * Project name : String description: String allocated : int TeachingProject RAndDProject DiverseProject * 1 Course One may have the description (i.e., code, name, sp) of the course in one separate class like CourseDescription and associate Course to this class (Course having year as attribute). code : String name : String sp : int year : int

13 (d) Typically a course is allocated 30 hours per study point
(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 (5X30), 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 Hours = 0 [else] [Hours>sp*30] Print: Course Name, study points and allocated hours [no project found] [project found] Hours = Hours + allocated hours Find next project connected to course


Download ppt "Exam Fall 2014 Proposed Solution"

Similar presentations


Ads by Google