public class ProperFraction
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
int |
denominator |
int |
numerator |
int |
wholeNumber |
| Constructor and Description |
|---|
ProperFraction(int wholeNumber,
int numerator,
int denominator)
This constructor should take three integers and make a ProperFraction object
Fractions cannot have a denominator of 0! If the denominator is 0, set the whole number to 0, the numerator to 0, and the denominator to 1.
|
ProperFraction(java.lang.String fraction)
This constructor should take a string such as "1 11/2" and make a ProperFraction object.
|
| Modifier and Type | Method and Description |
|---|---|
ImproperFraction |
makeImproper()
This method will take data from the ProperFraction object to produce an ImproperFraction
|
void |
simplify()
This method will simplify a fraction.
|
java.lang.String |
toString() |
public int wholeNumber
public int numerator
public int denominator
public ProperFraction(int wholeNumber,
int numerator,
int denominator)
wholeNumber - whole number for the fractionnumerator - numerator for the fractiondenominator - denominator for the fractionpublic ProperFraction(java.lang.String fraction)
fraction - a string holding the numbers for a fraction in the form of "wholeNumber numerator/denominator"public ImproperFraction makeImproper()
public void simplify()
public java.lang.String toString()
toString in class java.lang.Object