The remoting service
We will now add our remoting service. This remoting service will provide clients with the following two methods:
getList
: This method will return the list of animals.addAnimal
: This method will take a name and a number to create an animal and add it to the list of animals in the zoo.
In order to provide this service, we will simply create a class named Service
and implement the preceding two functions in it.
The getList function
The getList
function will simply return the list from the Zoo
class:
public static function getList() : List<Animal> { returnZoo.animals; }
Ok, this one was pretty simple in our case.
The createAnimal function
The addAnimal
method will create an instance of animal setting its name and number fields with the parameters it takes and adding it to the list of animals.
Here it is:
public static function createAnimal(name : String, quantity : Int) { //Create a new Animal instance var a = new Animal(); a.name = name...