Question: Write a program in PHP that defines a class titled MyInteger. The class is to hold a single integer that is set in the constructor

  1. Write a program in PHP that defines a class titled MyInteger. The class is to hold a single integer that is set in the constructor by a parameter. The class is to have methods isEven(int) and isOdd(int).
  2. In addition, the class will have an isPrime() method.
  3. Lastly, you are to have a getter and setter method.
  4. Create two instances and test all methods.
  5. Title the PHP class as MyInteger.
  6. Title the PHP file as MyFirstClass.php.

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!