1. What is the English words that specify an association? (3 marks) Name three associations for objects you can find in a house. (3 marks) Name three associations for objects you can find in a car. (3 marks) Name three associations for objects you can find in a soccer team. (3 marks) Name three associations for objects you can find in a bear. (3 marks) (total 15 marks)
2. What is the English words that signify an inheritance? (3 marks) Name three inheritances for objects you can find in a house. (3 marks) Name three inheritances for objects you can find in a car. (3 marks) Name three inheritances for objects you can find in a soccer team. (3 marks) Name three inheritances for objects you can find in a bear. (3 marks) (total 15 marks)
3. Use the Comparable interface to compare three Students based on their average mark. Create a Student class with name and mark. Create the following three Students and show a couple of examples of how one has a higher mark than the other. Add these students to an ArrayList and print thier names and average marks before and after sorting the list. (10 marks)
Student Mark ---------------- Andy 78 Behnaz 66 Charlie 93 Deepak 88
4. Use the Comparable interface to compare three Rectangles based on their surface area. Create a Rectangle class with instance variables name, width, and height, and create the following three Rectangles and add them to an ArrayList. Print thier name and surface area before and after sorting the list. (10 marks)
Name Width Height -------------------------- rectangle 0 50 4 rectangle 1 80 3 rectangle 2 90 2
Note that surface area = width * height.
5. Implement the equals() method for a Student class base on their Java 2 mark. Create a Student class with name and mark. Then create the following Students and test whether Andy, Charlie, and Behnaz are equal.
Student Mark ---------------- Andy 78 Behnaz 66 Charlie 78 Deepak 88
Your output should look something like this: Andy and Charlie are equal. Andy and Behnaz are not equal.
(10 marks)
6. Redo the last question from assignment 2. a.Draw the UML diagram of a clinic system. The system consists of Clinic, Doctor, and Patient classes. The patients are not related to the clinic directly. b.The clinic has a name and a list of doctors. Doctor has name and a list of patients. Patient has a name and a health issue. c.Draw a diagram for the above system on paper, embed it in a Word document, and submit a clear picture of it. d.In a file named Assignment3_6.java create all the classes: Clinic, Doctor, and Patient. e.Also create a test class named Assignment3_6 where you construct two or more instances of each class. f.Once you create your instances, tie them together to create the clinic system. g.Use clinic.describeYourself() method to output a text similar to the following.
List of Sheridan Health Centre patients: I am Peter , I have a cold I am Paula , I have a headache I am Paul , I have a bad shoulder I am Pamela, I have skin rash
(20 marks)