Q13 While designing a University Course Registration System suppose the

Q13 while designing a university course registration

This preview shows page 7 - 12 out of 15 pages.

Q13.While designing a University Course Registration System, suppose the software architect came up with three classes: CourseForm, CurriculumManagerand Course. Let the registrar of the university be an actor who interacts with the Course Registration System. Consider the following “Add a new course” scenario:1.The registrar interacts with the system by invoking the method setCourseInfoon an existing object aCourseFormof the class CourseForm. 2.The registrar then interacts with the system again by invoking the method processon the object aCourseForm. 3.Next the object aCourseForminvokes the methods addCourseon an existing object aManagerof the class CurriculumManager. 4.The object aManager, in turn, invokes the method newCourseon an existing object aCourseof the class Course. Draw the sequence diagram for the above scenario. Answer:
Image of page 7
8
Image of page 8
9 Q14. Consider the following method maxAof class Max. It can be used to calculate the index of the maximum element in array a(Note, "Comparable" objects hava a "compareTo(Comparable other)" method that returns a negative number if the otheris smaller, 0 if they are equal and a positive number if otheris bigger. Many classes implement the Comparable interface; for example, the Integer class--which wraps the primitive data type int into an object.) Write two JUnit test cases, testValidMaxA()and testInvalidMaxA(), to verify the behavior of the method maxA. testValidMaxA()should test the maxAmethod by providing it with valid arguments. testInvalidMaxA()should test the maxAmethod by providing it with invalid arguments. public class Max { public int maxA(Comparable [] a) { if ((a == null) || (a.length < 1)) throw new IllegalArgumentException("bad array"); int j = 0; int max = a[j]; for(int i = 1; i < a.length; i++) { if (a[i].compareTo(max) > 0) { max = a[i]; j = i; } } return j; } } .
Image of page 9
10
Image of page 10
11
Image of page 11
Image of page 12

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture