No collaboration is allowed on this program assignment. Your program must be an individual and original effort. Except for any situations explicitly identified in this assignment, if any, you may only receive help from your instructor or the tutors provided by the Computer Science Department. See the Syllabus for the significant consequences for disallowed collaboration and/or plagiarism.
ErrataNone so far - updates and corrections, if any, will show up here (be sure to refresh this page as necessary).
Due Date and Submission InstructionsSubmit the following file(s) on one of the CSL servers using handin as follows:
file(s): Fraction.java
touser: eaugusti
assignment/subdirectory: 102-program01c
ObjectivesYour source code must meet the Programming Guidelines.
Your solution must pass all test of the provided test driver (link and instruction provided below) when compiled and run on any the CSL servers.
Implement a class called Fraction to this specification. Your solution must only have the public methods specified here but you may write addtional private methods if you wish.
Use the minimally necessary number of instance variables of the appropriate type and maintaining encapsulation (private).
You must throw an IllegalArgumentException in certain situations (see specifications for when and where). Exceptions will be covered in greater detail later in the quarter, but for now, here is the Java code necessary to throw the specified exception:
Note that you must write
the
conditional logic
that determines when to throw or not throw the exception.
Develop incrementally, one method at a time, and use the tests you developed in Program 1b to ensure your work is correct. If you determine your tests are insufficient write more tests! Write a little code, compile, test, debug, fix, repeat until done.
Do not use the provided test driver (provided on the first due date for the assignment, not before) until your solution is complete and you believe it is correct.
Using the save-as feature of your browser (or wget/curl if you are a cool kid), not cut-and-paste, save P1cTestDriver.java - to be published on the first due date - in the same directory as your Fraction.java file.
Compile both P1cTestDriver.java and Fraction.java and run P1cTestDriver (see How to Compile and Run From the Command Line, as necessary). Remeber that your code will be graded on one of the CSL servers so, to avoid unpleasant grading surprises, be sure to test on any one of those machines at least once after all changes and just before handing in!