Be sure to write complete information in your blue exam book: Name, course, date, exam version B.
Question 1: The general structure of the Observer pattern as specified in your textbook, and some specifics of the "Gossip" example I have previously given you are paired below. Your job is to explain the correspondence in each pair.
Question 2: You are given the following test program for reference. (Hint: The classes in which methods are implmented are related to the corresponding interfaces.)
class TestCars { public static void main(String[] args) { Dealer DealerA = new DealerA(); Dealer DealerB = new DealerB(); Speed carA = DealerA.getACar(); Speed carB = DealerB.getACar(); System.out.println(carA.howFast() + " " + carB.howFast()); } // Output of the above is: "FAST! Not so fast" }
You are to write the following code, all with public access:
The hallmarks of the Factory Method are that an operation:
Using careful technical terms, discuss the above three points as they apply to the method getACar(). As part of this explain why carA.howFast() and carB.howFast() return distinct results. Hint: Discuss the apparent and actual types of carA and carB.