weaponwrath.java

来自「JAVA 工厂方法」· Java 代码 · 共 28 行

JAVA
28
字号
package org.su.demo.forge.items.Weapon;

import org.su.demo.forge.factory.CityIngredientFactory;

/*
 * 继承自武器的抽象基类
 * 锻造-雷霆-
 */
public class WeaponWrath extends Weapon {
	CityIngredientFactory cityIngredientFactory;
	//构造函数中取得一个工厂并储存到一个实例变量中
	public WeaponWrath(CityIngredientFactory cityIngredientFactory)
	{
		this.cityIngredientFactory = cityIngredientFactory; 
	}

	@Override
	public void prepare() {
		//从材料工厂得到正确的材料
		//雷霆需要3种材料
		this.ore = cityIngredientFactory.createOre();
		this.primal = cityIngredientFactory.createPrimal();
		this.potion =  cityIngredientFactory.createPotion();
		this.weaponName = "雷霆";
	}

}

⌨️ 快捷键说明

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