某大学设计模式试题 大家来做做
sun89 2008-11-25 11:32:25 6.Design a remote control program a on a Pocket PC device(which is a PDA based on
Microsoft Windows CE.Net),and support touch screen,GUI programming,and infrared port to
communicate with the TVs).The functions are almost the same with the common TV remote(such
as changing channel,volume,TV/AV change,ON/OFF and anything you think which should be on a
TV remote).The additional functions are the undo,redo command.
Based on MVC pattern,give an Object-Oriented Design using UML diagrams and written text
(plesase be in details)for the above requirements,.Explicitly all design patterns used and
justify your use of them.No code required.
5.There is a coffee shop to server HouseBlend and Espresso coffee.Each coffee can be
served with the following condiments:Milk,Mocha.Using Decorator pattern to construct the
coffee shop program to compute every beverage’s cost with its description.
Class beverage{
String decription;
String getDescription(){return description;}
Double cost();
}
Draw the pattern class diagram,and full code(class
CondimentDecorator,HouseBlend,Espresso,Milk,Mocha,StarBuzzCoffee and other classes
required) to construct the program including a test drive(StarBuzzCoffee class).
4.In object-oriented programming one is advised to avoid case(and if )statements.Select
one design pattern that helps avoid case statements and explain how it helps.
3.The Singleton Pattern relies on two key Java constructs or features to ensure that(1)at
most only one object of a class is ever created by clients,and (2)a reference to the
unique instance of the singleton class is always accessible to clients.Name and briefly
explain these features.
Write the code of this pattern.
2.Factory Method and Abstract Factory design patterns are quite similar.How are they
similar and how are they different?