About The Contest

The first ever Olympiad of Misguided Geeks contest at Worse Than Failure (or OMGWTF for short) is a new kind of programming contest. Readers are invited to be creative with devising a calculator with the craziest code they can write. One lucky and potentially insane winner will get either a brand new MacBook Pro or comparable Sony VAIO laptop.

Navigation

Advertisements

Entry #100170: StackCalc 070511

by Husted
All calculators looks the same to the end user.
What matters to programmers is how easy it is to maintain the application and add new functionality.
Using this stack based calculator it's very easy to add new functions, it's just a matter of registering a math operation and a function with the AddOp() function and implementing the said function, then the framework takes care of the rest.
Example:
This will register an ADDition operation with the add() function:
AddOp( ADD, Calc::add );
Then implement:
void Calc::add( float n1, float n2)
{
throw new CRes( n1 + n2 );
}

Download0 Comments