Question: Design a class named MyInteger . The class contains: An int data field named value that stores the int value represented by this object. A

Design a class named MyInteger. The class contains:

An int data field named value that stores the int value represented by this object.

A constructor that creates a MyInteger object for the specified int value.

A getter method that returns the int value.

The methods isEven(), isOdd(), and isPrime() that return true if the value in this object is even, odd, or prime, respectively.

The static methods isEven(int), isOdd(int), and isPrime(int) that return true if the specified value is even, odd, or prime, respectively.

The static methods isEven(MyInteger), isOdd(MyInteger), and isPrime(MyInteger) that return true if the specified value is even, odd, or prime, respectively.

The methods equals(int) and equals(MyInteger) that return true if the value in this object is equal to the specified value.

A static method parseInt(char[]) that converts an array of numeric characters to an int value. Do not use conversion functions to convert the numeric characters to an int.

A static method parseInt(String) that converts a string into an int value. Do not use conversion functions to convert the numeric string to an int.

Draw the UML diagram for the class then implement the class. Write a client program that tests all methods in the class.

Here is a sample run for n1 = 5, n2 = 24, numeric string "3539" and numeric character {'3', '5', '3', '9'}:

n1 is even? false

n1 is prime? true

15 is prime? false

3539

3539

n2 is odd? false

45 is odd? true

n1 is equal to n2? false

n1 is equal to 5? True

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!