2017-02-10 3 views
0

https://fsharpforfunandprofit.com/assets/img/uml-order.pngOOP PHPのコード内に1対多の関係がありますか?

これは実装されているクラス図ですが、1対多の関係はどのようなコードのように見えますか?

これは、クラス図は、多重のための任意の実装を強制するものではありません、私の質問

class Customer { 

    public $name; 
    public $location; 

    public function sendOrder(){ 
      //method here 
    } 

    public function receiveOrder(){ 
      //method here 
    } 

} 

class Order { 
    public $date; 
    public $number; 

    public function sendOrder(){ 
      //method here 
    } 

     public function receiveOrder(){ 
      //method here 
     } 
    } 

class SpecialOrder Extends Order{ 
    public function dispatch(){ 
     //method here 
    } 
} 

class NormalOrder Extends Order{ 
    public function dispatch(){ 
     //method here 
    } 

    public function receive(){ 
     //method here 
    } 
} 

答えて

0

を受け入れるStackOverflowのしてくださいテキストです。だからあなたはそれをどのように実装するのか自由です。最も簡単なものは、の中にCustomerという配列があります。私のPHPはかなり錆びていますが、おそらく次のようになります:

class Customer { 
    $orders = []; // references to orders 
    // rest of the class 
}