Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How to add four instance methods to the public interface of class 'Fraction'? Here is what I tried: https://codeshare.io/5Q18b7 Add four instance methods to the
How to add four instance methods to the public interface of class 'Fraction'?
Here is what I tried: https://codeshare.io/5Q18b7
Add four instance methods to the public interface of class 'Fraction': an instance method 'getNominator()' which returns the value of the instance variable 'nominator', an instance method 'getDenominator()' which returns the value of the instance variable 'denominator', an instance method 'setNominator' which sets the value of the instance variable 'nominator', and an instance method 'setDenominator' which sets the value of the instance variable denominator'. codeshare 1 class Fraction 2 { Integer nominator; Integer denominator; public Integer setNominator() { return nominator; public Integer setDenominator() { return denominator; public Integer getNominator() { return nominator; public Integer get Denominator() { return denominator; 22 } 23 24 class Main 25 [ 26 public static Fraction createFraction (Integer nominator, Integer denominator) 27 { Fraction result = new Fraction(); result.setNominator (nominator); result.setDenominator (denominator); return result; public static void main(String[] arguments), final Fraction HALF = createFraction (1, 2); final Fraction THREE FIFTH = createFraction (3, 5); System.out.println(toString (HALF)); System.out.println(tostring (THREE_FIFTH)); 41 } public static String tostring (Fraction fraction) return fraction.getNominator() + "/" + fraction.getDenominator(); 45 46 47 48] ]
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