Java
Implement a class MyInteger that contains:
• An int data field/instance variable named value that storesthe int value represented by this object.
• A constructor that creates a MyInteger object for a defaultint value. What default value did you choose? What other values didyou consider? Why did you make this choice?
• A constructor that creates a MyInteger object for a specifiedint value.
• A getter method, valueOf(), that returns value.
• A setter method, setValue(int), that replaces the currentvalue with the specified one and returns the original value.
• The method equals(int) that return true if the value in thisobject is equal to the specified value. This method will notoverride Object’s equals() method.
• The method toString() that returns a text (String) version ofvalue. toString() must include thousands grouping separators whenvalue is greater than 999. This method will override Object’stoString() method. You will need to use String.format() to get thedesired result.
• The static methods isZero(int), isEven(int) and isOdd(int)that return true if the specified value is zero, even or odd,respectively.
• The instance methods isZero(), isEven() and isOdd() thatreturn true if the value in this object is zero, even or odd,respectively. Do not duplicate the code in the static methods – usethem to do the work in the instance methods.
• The methods increment() and decrement() that increase ordecrease value by 1, respectively. These methods should both modifyvalue and return its new value.
• The instance methods add(int), subtract(int), multiplyBy(int),divideBy(int), and remainder(int), corresponding to the fivearithmetic operators (+, -, *, /, %). These methods should bothmodify value and return its new value.
Continue by adding the following:
• The instance method equals(Object) that return true if thevalue in this object is equal to the value of the specifiedinstance (the parameter – an instance of MyInteger). This methodwill override Object’s equals() method. You must check theparameter to make sure it’s not null and that it’s a MyIntegerbefore you can cast it to a MyInteger and interrogate itsvalue.
• The instance methods add(MyInteger), subtract(MyInteger),multiplyBy(MyInteger), divideBy(MyInteger), andremainder(MyInteger), corresponding to the five arithmeticoperators (+, -, *, /, %). These methods should both modify valuein this instance and return its new value. The specified instance(parameter) is unchanged.
• The methods isPrime() and isPrime(MyInteger) that return trueif the value in this object or the specified instance (parameter),respectively, is a prime number. isPrime() is an instance methodand isPrime(MyInteger) is a static method.
• The static methods parseInt(char[]) that converts an array ofnumeric characters to an int value and parseInt(String) thatconverts a String of numeric characters to an int value. You mustdo the conversions by hand (hint: subtract '0' from each digitcharacter to get its numeric value).
• Javadoc comments for all methods. Make sure you generate thedocumentation for all public elements.
Create a MyIntegerStudentTests to test all methods. Your testsshould include positive numbers, negative numbers, and zero asarguments and as the results of the operations. Make sure you testthe static and instance methods.
Your program should not do any input/prompting. The output ismostly up to you, but it should inform the user of the operationsunder test and the expected and actual results.