public interface EFactory
{
public Television produceTelevision();
public AirConditioner produceAirConditioner();
}
public class TCLFactory implements EFactory
{
public Television produceTelevision()
{
return new TCLTelevision();
}
public AirConditioner produceAirConditioner()
{
return new TCLAirConditioner();
}
}
public interface Television
{
public void play();
}
public interface TVFactory
{
public TV produceTV();
}
public class HaierTelevision implements Television
{
public void play()
{
System.out.println("�������ӻ�������......");
}
}
public class HairAirConditioner implements AirConditioner
{
public void changeTemperature()
{
System.out.println("�����յ��¶ȸı���......");
}
}
public class Client
{
public static void main(String args[])
{
try
{
EFactory factory;
Television tv;
AirConditioner ac;
factory=(EFactory)XMLUtil.getBean();
tv=factory.produceTelevision();
tv.play();
ac=factory.produceAirConditioner();
ac.changeTemperature();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}