testprototype.java

来自「仅学习使用」· Java 代码 · 共 22 行

JAVA
22
字号
package prototype;

public class TestPrototype {
	public static void main(String[] args) {
		System.out.println( "Creating a Prototype Factory with a SoupSpoon and a SaladFork");
		PrototypeFactory prototypeFactory = new PrototypeFactory(new SoupSpoon(), new SaladFork());
		AbstractSpoon spoon = prototypeFactory.makeSpoon();
		AbstractFork fork = prototypeFactory.makeFork();
		System.out.println("Getting the Spoon and Fork name:");
		System.out.println("Spoon: " + spoon.getSpoonName() + ", Fork: " + fork.getForkName());
		System.out.println(" ");

		System.out.println( "Creating a Prototype Factory with a SaladSpoon and a SaladFork");
		prototypeFactory = new PrototypeFactory(new SaladSpoon(), new SaladFork());
		  
		spoon = prototypeFactory.makeSpoon();
		fork = prototypeFactory.makeFork();
		System.out.println("Getting the Spoon and Fork name:");
		System.out.println( "Spoon: " + spoon.getSpoonName() + ", Fork: " + fork.getForkName()); 
	} 
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?