官术网_书友最值得收藏!

Abstract Factory in action

Our strategy game will consist of buildings and units. Let's start with declaring what all buildings share:

interface Building<in UnitType, out ProducedUnit> 
where UnitType : Enum<*>, ProducedUnit : Unit {
fun build(type: UnitType) : ProducedUnit
}

All buildings should implement the build() function. Here we see generics in Kotlin for the first time, so let's discuss them a bit.

主站蜘蛛池模板: 菏泽市| 杭锦后旗| 团风县| 台南县| 巴马| 天峨县| 正定县| 尼木县| 乐山市| 武宣县| 寿阳县| 通山县| 乌兰县| 偃师市| 铅山县| 时尚| 辉南县| 惠州市| 清水县| 墨玉县| 沁源县| 东丰县| 铜梁县| 修文县| 洛川县| 阜新市| 杭锦后旗| 北票市| 河北区| 巴彦县| 昆山市| 图们市| 仲巴县| 大名县| 皮山县| 北海市| 张家港市| 宝山区| 新巴尔虎左旗| 调兵山市| 东兰县|