Question 1. You are in charge of developing a travel website which allows a user to book flight tickets as well as hotel rooms. The booking process is as follows: a user receives recommendations from the system as to flight tickets or hotels; then the user makes the selection, adds it to the shopping cart, and makes the payment. There are different algorithms for recommending flight tickets or hotels. The payment system, however, remains the same. The user can use either a credit card or a debit card to pay the bill. Use the bridge design pattern to design and implement a solution. First, draw a class diagram to illustrate the software design. Then, provide a skeleton implementation in Java.
[Hint] Following the bridge terminology, the abstractions are the booked items (flight tickets or hotels). The implementations are payment methods (credit card or debit card). You do not need to worry about details such as exactly how each payment method works or how to actually recommend flight tickets or hotels. Focus on the classes, and the relationship (inheritance and aggregation) between them.
Question 2. Consider the online shopping website, which we (partially) implemented in Question 5 of Assignment 4. In that assignment, we focused on currency conversion. Now you are asked to extend that solution to deal with the problem of delivery: depending on the location of the consumers (US, UK and Canada), the system is supposed to automatically display the address and telephone number in the correct format. Use the Abstract Factory design pattern to design a subsystem that handles proper initiation of the objects taking care of these display problems. Draw a class diagram to illustrate the software design. Then, provide a skeleton implementation in Java.
[Hint] In your skeleton implementation, do NOT actually implement the code to correctly display country-specific address and telephone numbers. Just producing something output such as Printing US/UK/Canada addresses and phone numbers in the corresponding methods. Rather, focus on how to organize different classes following Abstract Factory.
The manager of ABC company asks you to build a comprehensive search application that makes use of both Google and Bing search engines. This search application will have the same processing steps, no matter which underlying search engine will be used. These common steps include
Use the Template Method pattern to develop this application. Draw a class diagram to show the software design. Provide a skeleton implementation in Java.
[Hint] Define these common steps in the base class. Differences in Google/Bing Web APIs should be handled in the derived classes. There is NO need to actually study or use Google/BIN APIs since this is just a skeleton implementation. There is NO need to actually interact with the user to receive the search keywords.
This question extends the Question 1. Use the Singleton pattern to make sure that the search engine service objects are initiated at most once. Draw a class diagram to illustrate your solution. Provide a skeleton implementation in Java.
This is based on the Search Engine question.