2016-11-23 56 views

回答

0

我preusume你指的是這幅畫(維基百科借來的):

builder pattern

Builder只會是接口(意味着沒有實現)和ConcreteBuilder是接口的實行。 ConcreteBuilder將處理其它目的

實施例的創建:

// Builder interface 
public interface ICarBuilder 
{ 
    void SetColour(string colour); // no implementation 
} 

// ConcreteBuilder implementation 
public class CarBuilder: ICarBuilder 
{ 
    private Car _car; 

    public CarBuilder() 
    { 
     this._car = new Car(); 
    } 

    // implementation 
    public void SetColour(string colour) 
    { 
     this._car.Colour = colour; 
    } 
}