Question
Program: FracturedFraction implementation of the WackyFractionlnterface Develop a Java class called FracturedFraction that correctly implements the WackyFractionlnterface. Download a copy of this interface here-WackyFractioninterfacejava The
Program: FracturedFraction implementation of the WackyFractionlnterface Develop a Java class called FracturedFraction that correctly implements the WackyFractionlnterface. Download a copy of this interface here-WackyFractioninterfacejava The WackyFractionInterface that models a fractional number as a numerator divided by a denominator. This fractional number can be represented as the quotient of two integers. For example, 1/2, 3/4, and so forth are all rational numbers (in this case, we mean the mathematical meaning of the fraction, not the integer division this expression would produce in a Java program.) Your class will represent rational numbers as two values of type int, one for the numerator,and one for the denominator.
Your class should have two instance variables of type int. An additional constraint of a WackyFraction is that a numerator or denominator must be a positive, non-zero integer. In order to uphold encapsulation, your FracturedFraction class must uphold this restriction. Include two constructors to your FracturedFraction class - one that accepts two integers as arguments and a second no-arg constructor. The no-argument constructor should set both of the instance variables to 1. Here are the method headers for your constructors: public FracturedFraction(int numerator int denominator) public FracturedFraction() The semantics of the methods in the interface are specified in this document. Each of these methods must accept a WackyFractionInterface object as the single parameter. If you have any questions on the specification, please ask for clarification on the Discussion Board forum in Canvas.
Write this program in JAVA and compile it in JDK 11.
WackyFractionInterface.java is below
package cmsc256; /** This interface describes the operations of a wacky fraction. Forget all those boring rules of mathematics, we're going wacky WackyFractions have a numerator, denominator, and a sign. */ public interface WackyFractionInterface extends Comparable
public WackyFractionInterface getReciprocal(); /** Compares this fraction to another fraction to determine which one is larger, or if they are equal, without changing either one. @param other The other fraction we are comparing to this fraction. @return An integer representing how the fractions compare. */ public int compareTo(final WackyFractionInterface other); // The methods equals and toString are defined in and inherited from Object. // They should be overridden in any class that implements this interface. }
add: ba+dc=b+da+c subtract: badc=Min(b,d)(ac). Note: this is a correction. multiply: badc=bdac divide: badc=adbc getReciprocal(): returns the reciprocal, for example baab compareTo(WackyFractionInterface other) Upholds the standard contract of the ComparablecE> interface in Java; Compares this fraction to another fraction to determine which one is larger, or if they are equal, without changing either one The methods equals and toString() are defined in and inherited from Object. They should be overridden in any class that implements this interface following the standard contract for these methods as defined in the Object class. - Hint: Two fractional numbers a/b and c/d are equal if a+ equals cb. - The format of the toString() should be simply "numerator/denominator". For example, 1/2Step 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