Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  1. A constructor that takes a numerator and denominator as arguments
  2. Getters for both the numerator and denominator.
  3. Utilize the reduce method I've provided for you.
  4. 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:

  1. 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)
  2. 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:

  1. Overload the \"*\" operator when multiplying to another fraction and to a number like a int or long
  2. 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:

  1. Overload the \"==\" operator
  2. Overload the \"!=\" operator
  3. Overload the \">\" operator
  4. Overload the \"\">
  5. Overload the \">=\" operator
  6. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions