Implement a simple class in your favorite language.

Posted by Oscar Reyes on Stack Overflow See other posts from Stack Overflow or by Oscar Reyes
Published on 2010-04-23T23:05:02Z Indexed on 2010/04/23 23:13 UTC
Read the original article Hit count: 280

I'm doing this to learn syntax of different programming languages.

So, how would you defined the following class along with with it's operations in your favorite programming language?

alt text

Image generated by http://yuml.me/

And a main method or equivalent to invoke it:

For instance, for Java it would be:

...
public static void main( String [] args ) {
    Fraction f = new Fraction();
    f.numerator( 2 );
    f.denominator( 5 );
    f.print();
}
....

© Stack Overflow or respective owner

Related posts about language-showcase

Related posts about language-agnostic