diff --git a/Exe2/ConsumptionController.php b/Exe2/ConsumptionController.php new file mode 100644 index 0000000..878a3e2 --- /dev/null +++ b/Exe2/ConsumptionController.php @@ -0,0 +1,34 @@ + + */ +class ConsumptionController { + private $model; + + /** + * + * Contructor + * + */ + public function __construct($model) { + $this->model = $model; + } + + /** + * + * Exec calc the consuption + * + * @param array $request Form's informations + */ + public function calc($request) { + if (isset($request['fuelQtd']) && isset($request['milesQtd'])) { + $this->model->set($request['fuelQtd'], $request['milesQtd']); + } + } +} +?> \ No newline at end of file diff --git a/Exe2/ConsumptionModel.php b/Exe2/ConsumptionModel.php new file mode 100644 index 0000000..dab7943 --- /dev/null +++ b/Exe2/ConsumptionModel.php @@ -0,0 +1,37 @@ + + */ +class ConsumptionModel { + private $milesQtd = 0; + private $fuelQtd = 0; + + /** + * + * Get Fuel Consuption + * + * @return float Fuel Consumption + */ + public function get() { + return round($this->milesQtd / $this->fuelQtd, 2); + } + + /** + * + * Set parameters values to calc the consuption + * + * @param float $fuelQtd Qtd Fuel + * @param float $milesQtd Qtd Miles + */ + public function set($fuelQtd, $milesQtd) { + $this->fuelQtd = $fuelQtd; + $this->milesQtd = $milesQtd; + } + +} +?> \ No newline at end of file diff --git a/Exe2/ConsumptionView.php b/Exe2/ConsumptionView.php new file mode 100644 index 0000000..4afd522 --- /dev/null +++ b/Exe2/ConsumptionView.php @@ -0,0 +1,43 @@ + + */ +class ConsumptionView { + private $calc; + + /** + * + * Contructor + * + */ + public function __construct(ConsumptionModel $calc) { + $this->calc = $calc; + } + + + /** + * + * Output + * + * @return HTML - form and fields + */ + public function output() { + $html = '
'; + + return $html; + } +} +?> \ No newline at end of file diff --git a/Exe2/index.php b/Exe2/index.php new file mode 100644 index 0000000..58c723f --- /dev/null +++ b/Exe2/index.php @@ -0,0 +1,15 @@ +{$_GET['action']}($_POST); + +$gallonView = new ConsumptionView($model); + +echo $gallonView->output(); +?> \ No newline at end of file