Design and implement a service that simulates PHP loops. Each of the three loop variants should be encapsulated in an object. The service can be controlled via a parameter and execute three different...


Design and implement a service that simulates PHP loops. Each of the three loop variants should be encapsulated in an object. The service can be controlled via a parameter and execute three different simulations. The result is returned as JSON.


The input is an array consisting of the letters $characters = [A-Z].


-The For loop should store all even letters in an array.
-The Foreach loop simulation is to create a backward sorted array by For loop, i.e. [Z-A] .
-The While loop should write all characters into an array until the desired character is found.


Interface:
-GET Parameter String: loopType ( possible values: REVERSE, EVEN, UNTIL )
-GET parameter String: until (up to which character)


Output:
JSON Object: {loopName: , result: }



Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here