Question: ***NEED HELP ASAP PLEASE WITH THIS PROBLEM!** - SIMPLE UNDERSTANDING PLEASE! Consider the following interface for unary integer functions and example implementation: interface Fun {
***NEED HELP ASAP PLEASE WITH THIS PROBLEM!** - SIMPLE UNDERSTANDING PLEASE!

Consider the following interface for unary integer functions and example implementation: interface Fun { public int eval(int i); } class Inc implements Fun { public int eval(int i) { return i+1; }} (a) Write code for class C. Class C composes two functions (that is, when given an argument C.eval applies the first function to the argument and the second function to the result of the first, returning the result of the second function). As an example of usage, consider the following: Fun inc = new Inc(); System.out.println (inc.eval(2)); // prints 3 Fun t5 = new TimesN(5); System.out.println (t5.eval(2)); //prints 10 Fun f = new C(t5,t5); System.out.println (f.eval(2)); // prints 50 Fun g = new C(f,inc); System.out.println (g.eval(2)); // prints 51 (b) Writing a JUnit Test. In new C(F1,F2).eval(n), we wish to ensure that f1.eval is performed before f2.eval. Write a unit test for class C to ensure that this is the case
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
