PHP Classes

File: command.php

Recommend this page to a friend!
  Classes of Nemeth Zoltan   Design patterns   command.php   Download  
File: command.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Design patterns
Implements several well known design patterns
Author: By
Last change:
Date: 7 years ago
Size: 738 bytes
 

Contents

Class file image Download
<?php
/**
 * Created by PhpStorm.
 * User: nemeth.zoltan
 * Date: 2016. 05. 13.
 * Time: 15:17
 */
include __DIR__ . '/vendor/autoload.php';

//
// Részvény
//
$stock = new \DP\Command\Model\Stock();

//
// Brókerek
//
$brokers = array();
$brokers[] = new \DP\Command\Model\Broker('Broker Béla');
$brokers[] = new \DP\Command\Model\Broker('Broker Elemér');

foreach (
$brokers as $broker) {
    for (
$i = 0; $i <= 10; $i++) {
        if (
mt_rand(0, 1)) {
           
$broker->placeOrder(new \DP\Command\Command\Buy($stock));
        } else {
           
$broker->placeOrder(new \DP\Command\Command\Sell($stock));
        }
    }
    echo
'<br>' . $broker;
    echo
'<br><strong>Place orders</strong><br>';
   
$broker->closeDay();
}