看明白了吗?好了,我们该让尊敬的、永远高贵的客户出场了,只有他,唯有他才有决定用哪种数据库的最高权限,你看,他这样用:
public class Client
{
public static void Main()
{
//Get the database information from Web.Config.
string DBType = ConfigurationSettings.AppSettings["DBType"];
string DBConnectString = ConfigurationSettings.AppSettings["DBConn"];
IDatabase DB = Factory.SelectDatabase(DBType);
//Connect the selected database.
if(DB.Connect(DBConnectString)==false)
{
Console.WriteLine("The database {0} can@#t be connected.",DBType);
return;
}
//Open database.
if(DB.Open()==false)
{
Console.WriteLine("The database {0} can@#t be opened, the connect string is {1}.",DBType,DBConnectString);
return;
}
//Execute SQL Command.
string SQL = "update Order set price = price * 0.07 where productID = @#002@#";
if(DB.Command(SQL))
{
//Do something...
}
else
{
Console.WriteLine("The Operator is not success. SQL statament is {0}",SQL);
DB.Close();
return;
}
DB.Close();
}
}
好了,工程峻工了,你们明白了没有?
思考题:简单工厂的应用场合和局限性?
作业题:假如要开发一个多媒体播放器,既能用Window MediaPlayer播放,又能用RealPlayer播放,还能用QuickTime播放,具体用什么播放器,由客户选择,请你画出UML图并写出代码。

