用一套方法論去設計許多方法來解決工程上遇到的問題。 即 "一生萬法、萬法圓通"。

Recent in Recipes

3/Food/post-list

DP1 抽象工廠 Section1.2 Abstract Factory

沒有留言

 代碼布局(佈陣)


1. FrogWorld 和 WizardWorld 代表抽象工廠。因為是Python的關係,所以它把上一階應該要有的Interface約定省略掉了,而透過 make_character 和 make_obstacle 來實作共同的接口。 In a statically typed language, the Abstract Factory would be an abstract class/interface with empty methods, but in Python this is not required because the types are checked in runtime. (因為對Python定義一個空的Class 是沒有實質意義的)
2. The GameEnvironment is the main entry point of our game. It accepts factory as an input, and uses it to create the world of the game. 
3. The play() method initiates the interaction between the created hero and the obstacle







沒有留言 :

張貼留言