1a) B B r r e 1b) r e v e l 2a) A number of possibilities. Here is one: public Course [] getList(int dept, String prefix){ Course [] courses = new Course[numCoursesOfDept[dept]]; // Create array object int j=0; for(int i=0; i < numCourses; i++){ // Step through courseArray if (courseArray[i].isOfType(prefix)){ // If course in courseArray is from right dep't courses[j] = courseArray[i]; // copy the reference to our new array object j++; // Make index point at next null pos'n in courses } } return courses; // Return reference to array object that we } // just filled. 2b) Number of different ways to do this. Some principles follow. You could get full marks by discussing 2/3 of the following. - need to write a main method which makes a number (see below) of calls to addCourse() - good idea to write a toString() method for CourseList so that the contents of the list can be printed easily. This might be called after each call to addCourse() so that the result of the operation of addCourse() can be inspected - Cover data: want to make calls to addCourse() with different arguments: dept: negative integer, zero, positive integer < 3, positive integer > 2 prefix: "", null, one small letter, one capital letter, 3 small letters, 3 capital letters, 4 small letters, 4 capital letters, very long string Note that there are 3X9=27 possibilities here, but MAX_COURSES is set to 5. Must either change MAX_COURSES for testing purposes, or run these test cases 5 at a time. - Cover code: the 'if' block doesn't get executed unless we add more than 5 courses, so pick 6 addCourse() calls which will succeed, and run. 3) Note on formatting: you should either write this as they do in the text, where they write something that looks like a class but put comments in place of the methods, or you should write a chart, like the following: Knowing Responsibilities - 3 instance variables, private, int to represent the three guesses - 3 instance variables, private, int to represent the three numbers in the combination Doing Responsibilities - 3 public methods, int parameter, return void, to set the guesses - 3 public methods, no parameter, return int, to get the guesses - Constructor, 3 int parameters, set the combination variables - public method, no parameter, returns true if and only if each of the three guesses equals the corresponding integer in the combination - reset method, no parameter, returns void, sets all guesses to zero Bonus Question 4 Stages: Specification, Design, Implementation, Verification Specification - establish what the goals and constraints are for the software - usually in consultation with the people who will use the software when it is finished Design - describe overall architecture, including what classes there will be and what they represent - assign knowing and doing responsibilities to classes Implementation - translate the design into code Verification - test to make sure that the software runs without failure - test to make sure the software does what it is supposed to do (compare to specification) Often problems encountered at one stage will require revising work done at an earlier stage.