打印

这段文字是什么意思,求翻译.谢谢了

Creator Classes
Example 2-4 through Example 2-6 show the creator classes. As with the product
classes, all creators belong to the package example. The creator classes are defined as
public, which indicates that they are publicly accessible from outside the package.
The creator class, as indicated by the comments, should behave as an abstract class.
It should be subclassed and not be instantiated. It also defines the factory method
that should behave as an abstract method. Note that the two concrete creator classes
CreatorA and CreatorB extend Creator. They also override and implement the
factoryMethod( ) method, each returning a corresponding product object. In addition,
the factoryMethod( ) declared in the Creator class has to return null to prevent
a compile-time error. It will also throw an IllegalOperationError if called directly.
This is a runtime check to make sure that this method is overridden.
Example 2-4. Creator.as
package example
{
import flash.errors.IllegalOperationError;
// ABSTRACT Class (should be subclassed and not instantiated)
public class Creator
{
public function doStuff( ):void
{
var product:IProduct = this.factoryMethod( );
product.manipulate( );
}
// ABSTRACT Method (must be overridden in a subclass)
protected function factoryMethod( ):IProduct
{
throw new IllegalOperationError("Abstract method:
must be overridden in a subclass");
return null;
}
}
}
Example 2-5. CreatorA.as
package example
{
public class CreatorA extends Creator
{
override protected function factoryMethod( ):IProduct
{


trace("Creating product 1");
return new Product1( ); // returns concrete product
}
}
}
Example 2-6. CreatorB.as
package example
{
public class CreatorB extends Creator
{
override protected function factoryMethod( ):IProduct
{
trace("Creating product 2");
return new Product2( ); // returns concrete product
}
}
}
Note that the doStuff( ) method in the Creator class is declared as public because we
need to allow clients to get to it from outside the package. In contrast, the
factoryMethod( ) is declared as protected. The protected attribute makes the method
visible only within the same class or derived classes. Finally, we can take a look at the
document class called Main, which is the client described in the class diagram shown
in Figure 2-2 that uses the creator to access products.
Clients
The document class Main does not belong to a named package. Therefore, it must
import the packages that contain the classes it uses. The example package needs to be
imported, as it contains the creator classes. The document class Main is the client
described in the high-level model of the factory method pattern shown in Figure 2-1.
In Example 2-7, the document class calls a static method called run( ) in the static
Test class to run some tests.
这段文字讲了Creator这个抽象类,并通过两个例子来说明这个类的使用。
Creator A和Creator B都继承了Creator类。
还介绍了Creator A 和Creator B 里的方法的作用, 具体作用什么的可以看代码里的注释!

翻译完整很不爽,看个大概猜猜也就差不多啊
熊熊,大雨就快停了,彩虹也要出来啊。