protected function toRoman($number) { $u = new Unit(); if ($number % $this->numberUnit == 0) { return $this->hundred[$number / $this->numberUnit - 1]; } else { return $this->hundred[$number / $this->numberUnit - 1] . $u->convert($number % $this->numberUnit); } }
/** * Standardize and calculate the total of multiple weights * * It's probably faster in theory to convert only the total to the final unit, and not each product weight. * However, we might loose precision, not sure about that. * Based on formulas found at http://jumk.de/calc/gewicht.shtml * @param array * @param string * @return mixed */ public function amountIn($strUnit) { if (empty($this->arrWeights)) { return 0; } $fltWeight = 0; foreach ($this->arrWeights as $objWeight) { if ($objWeight->getWeightValue() > 0) { $fltWeight += Unit::convert(floatval($objWeight->getWeightValue()), $objWeight->getWeightUnit(), Unit::KILOGRAM); } } return Unit::convert($fltWeight, Unit::KILOGRAM, $strUnit); }
/** * @todo Finalize implementation of this method. */ protected function toRoman($number) { $u = new Unit(); if ($number % $this->numberUnit == 0 && $number < 10000) { return $this->thousand[$number / $this->numberUnit - 1]; } else { if ($number < 10000) { return $this->thousand[$number / $this->numberUnit - 1] . $u->convert($number % $this->numberUnit); } else { return 'Fail'; } } }
<?php error_reporting(E_ALL); ini_set('display_errors', 1); require_once 'ConverterRomanNumerals.class.php'; require_once 'Unit.class.php'; require_once 'Dozen.class.php'; require_once 'Hundred.class.php'; require_once 'Thousand.class.php'; $u = new Unit(); echo '0 - ' . $u->convert(0) . '<br />'; echo '1 - ' . $u->convert(1) . '<br />'; echo '2 - ' . $u->convert(2) . '<br />'; echo '3 - ' . $u->convert(3) . '<br />'; echo '5 - ' . $u->convert(5) . '<br />'; echo '7 - ' . $u->convert(7) . '<br />'; echo '9 - ' . $u->convert(9) . '<br />'; echo '10 - ' . $u->convert(10) . '<br />'; echo '20 - ' . $u->convert(20) . '<br />'; echo '24 - ' . $u->convert(24) . '<br />'; echo '26 - ' . $u->convert(26) . '<br />'; echo '40 - ' . $u->convert(40) . '<br />'; echo '50 - ' . $u->convert(50) . '<br />'; echo '70 - ' . $u->convert(70) . '<br />'; echo '90 - ' . $u->convert(90) . '<br />'; echo '92 - ' . $u->convert(92) . '<br />'; echo '94 - ' . $u->convert(94) . '<br />'; echo '95 - ' . $u->convert(95) . '<br />'; echo '99 - ' . $u->convert(99) . '<br />'; echo '101 - ' . $u->convert(101) . '<br />'; echo '111 - ' . $u->convert(111) . '<br />';