next up previous
Next: Modifers Up: Assignment 9: Rational Numbers Previous: Rational numbers

Another constructor

1.
Write a second constructor for your class that takes two integers as arguments and that uses them to initalize the instance variables. It may be tempting to name the arguments num and den, but you will find that that creates problems (we will discuss them in detail later). For now it is best to give them different names like numer and denom.
2.
Add lines to main that test both constructors. You will probably want to add a print statement to each constructor so that you can tell exactly when each constructor gets invoked.



Allen B. Downey
4/8/1998