Question
The Function ADT Class Start your work by completing the tests in Base fraction test file. In order to get these tests to pass you'll
The Function ADT Class
Start your work by completing the tests in Base fraction test file. In order to get these tests to pass you'll need to set up:
- A constructor that takes a numerator and denominator as arguments
- Getters for both the numerator and denominator.
- Utilize the reduce method I've provided for you.
- Throw an exception, with descriptive text, if a fraction is created with a denominator of zero.
Addition and Subtraction
You can do the remaining 3 tests in any order. Note they will not compile until you've added all the operator methods so you should start with that. For the Addition and Subtraction tests to pass you'll need to:
- Overload the \"+\" operator when adding to another fraction and to a number like a int or long (Hint: If you create the method for a long, then ints will work too)
- Overload the \"-\" operator when subtracting by another fraction and by a number like a int or long
Multiplication and Division
For the Multiplication and Division tests to pass you'll need to:
- Overload the \"*\" operator when multiplying to another fraction and to a number like a int or long
- Overload the \"/\" operator when dividing by another fraction and by a number like a int or long
Comparison
For the comparison tests to pass you need to:
- Overload the \"==\" operator
- Overload the \"!=\" operator
- Overload the \">\" operator
- Overload the \"\">
- Overload the \">=\" operator
- Overload the \"=\">
Note:You only need to compare with other fraction objects.
Style
Style counts, comment you code, use good variable names, use good spacing and formatting. Make your code nice and readable.
Note:If you are using a IDE other than cLion it may try and build off the test files every time. In which case it will not compile because it's up to you to write the methods this time. Knowing how to overload an operator is part of the assignment. If that's the case for you you'll need to create stub methods for all the operators before you begin testing using the provided tests.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started