摘要:
package designPattern;//creatorclass MazeGame{ public Maze CreateMaze() { Maze aMaze = MakeMaze(); Room r1 = MakeRoom(1); Room r2 = MakeRoom(2); Door theDoor = MakeDoor(r1, r2); aMaze.AddRoom(r1); aMaze.AddRoom(r2); r1.SetSide(North, MakeWall()); r1.SetSide(East, theDoor); r1.SetSide(So... 阅读全文
摘要:
package designPattern;//builder base class//为创建product的各个部件指定抽象接口class MazeBuilder{ public void BuildMaze() { } public void BuildRoom(int n) { } public void BuildDoor(int roomFrom, int roomTo) { } public Maze GetMaze() { return null; } protected MazeBuilder() { }}//Director use builder//可以控... 阅读全文
摘要:
package designPattern;//Abstract factory//定义生产各个产品的接口class MazeFactory{ public Maze MakeMaze() { return new Maze(); } public Door MakeDoor(Room r1, Room r2) { return new Door(r1, r2); } public Room MakeRoom(int n) { return new Room(n); } public Wall MakeWall() { return new Wall(); }}//client use... 阅读全文