Question: Code must be in java. Create a class Int with the following components: a. A field to store an int value. b. A constructor so
Code must be in java.

Create a class Int with the following components: a. A field to store an int value. b. A constructor so that new Int (x) creates an Int object that stores the int value x. c. An instance method toString so that x.toString () returns the value of the Int object x in String form. d. An instance method plus so that x.plus (y) returns a new Int object whose value is the value of the Int x plus the value of the Int y. There should be no side effects. e. Instance methods minus, times, and div, similar to the plus method described above. (The div method should perform integer division, like the/operator on int values.) f. An instance method isPrime so that x.isPrime () returns true if the value of the Int x is a prime number. In some object-oriented languages, like Smalltalk, absolutely everything is an object-integers, booleans, characters, strings, everything. In such languages, arithmetic really works a bit like this exercise, though the language may provide a more natural syntax for operators
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
