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

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.

主站蜘蛛池模板: 象州县| 漯河市| 深圳市| 九江市| 江西省| 岳西县| 万载县| 苍南县| 凌海市| 神木县| 连江县| 阿克苏市| 太谷县| 合川市| 荆州市| 双城市| 清水县| 尉氏县| 洛浦县| 从江县| 格尔木市| 昭平县| 沁水县| 长泰县| 靖西县| 兴安县| 乐山市| 永仁县| 娱乐| 扎兰屯市| 金坛市| 炎陵县| 佛冈县| 澄江县| 临洮县| 石泉县| 乌兰县| 黄大仙区| 扶风县| 富顺县| 夏津县|