Package edu.kirkwood.controller
Class MarcsFractionCalculator
java.lang.Object
edu.kirkwood.controller.MarcsFractionCalculator
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FractionparseFraction(String str) Converts a String into a Fraction object.static String[]splitInput(String input) Split the user input into three parts: fraction 1, operator, fraction 2static voidstart()
-
Constructor Details
-
MarcsFractionCalculator
public MarcsFractionCalculator()
-
-
Method Details
-
start
public static void start() -
splitInput
Split the user input into three parts: fraction 1, operator, fraction 2- Parameters:
input- the raw input string from the user- Returns:
- String[] array with three Strings
- Throws:
IllegalArgumentException- if input or operator are invalid
-
parseFraction
Converts a String into a Fraction object. Handles whole numbers, improper and proper fractions, and mixed numbers- Parameters:
str- The String representing a fraction to be parsed- Returns:
- a Fraction object representing the parsed String
- Throws:
IllegalArgumentException- if the String's fraction format is not valid.
-