You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now there is only one SimpleNumberStringParser, but it works only for base 10 numbers.
Think about the following code, adding a base 8 number and a base 10 number.
numberCollection = new NumberCollection();
$numberParser = new SimpleNumberStringParser(8);
$firstParsedNumber = $numberParser->parse('10');
$firstNumber = new SimpleNumber($firstParsedNumber);
$firstNumberProxy = new CollectionItemNumberProxy($firstNumber);
$numberCollection->add($firstNumberProxy);
$numberParser = new SimpleNumberStringParser();
$secondParsedNumber = $numberParser->parse('1');
$secondNumber = new SimpleNumber($secondParsedNumber);
$secondNumberProxy = new CollectionItemNumberProxy($secondNumber);
$numberCollection->add($secondNumberProxy);
$addition = new AdditionOperator('SimplePHPEasyPlus\Number\SimpleNumber');
$operation = new ArithmeticOperation($addition);
$engine = new Engine($operation);
$calcul = new Calcul($engine, $numberCollection);
$runner = new CalculRunner();
$runner->run($calcul);
$result = $calcul->getResult();
$numericResult = $result->getValue(); // 10
While this does still work it get ugly for international numbers my enterprise class code has to deal with: (We are a startup marketing world wide).
numberCollection = new NumberCollection();
$numberParser = new RomanNumberStringParser();
$firstParsedNumber = $numberParser->parse('XMIV');
$firstNumber = new SimpleNumber($firstParsedNumber);
$firstNumberProxy = new CollectionItemNumberProxy($firstNumber);
$numberCollection->add($firstNumberProxy);
$numberParser = new SimpleHanNumberStringParser();
$secondParsedNumber = $numberParser->parse('三十三');
$secondNumber = new SimpleNumber($secondParsedNumber);
$secondNumberProxy = new CollectionItemNumberProxy($secondNumber);
$numberCollection->add($secondNumberProxy);
$addition = new AdditionOperator('SimplePHPEasyPlus\Number\SimpleNumber');
$operation = new ArithmeticOperation($addition);
$engine = new Engine($operation);
$calcul = new Calcul($engine, $numberCollection);
$runner = new CalculRunner();
$runner->run($calcul);
$result = $calcul->getResult();
$numericResult = $result->getValue(); // 937
Obviously a factory for SimpleHanNumberStringParser and RomanNumberStringParser would be helpfull. It should deal with 1) encoding 2) the base of the number 3) local numerology (such a 666 or 13 in the western world or 4 in japan). I haven't figured out how to implement it, but i think it would make the code a way more productive.
The text was updated successfully, but these errors were encountered:
Right now there is only one SimpleNumberStringParser, but it works only for base 10 numbers.
Think about the following code, adding a base 8 number and a base 10 number.
While this does still work it get ugly for international numbers my enterprise class code has to deal with: (We are a startup marketing world wide).
Obviously a factory for SimpleHanNumberStringParser and RomanNumberStringParser would be helpfull. It should deal with 1) encoding 2) the base of the number 3) local numerology (such a 666 or 13 in the western world or 4 in japan). I haven't figured out how to implement it, but i think it would make the code a way more productive.
The text was updated successfully, but these errors were encountered: