E
E
Eban2019-10-26 16:50:50
Java
Eban, 2019-10-26 16:50:50

Interfaces and their implementation in java?

I have an API with a findRooms(int price) method and two implementations of BookingAPI and GoogleApi
and have a Controller class and an API[] apis array and a requestRoom(int price) method
here are my attempts:

public class Controller {
    API[] apis;
Room[] requestRooms(int price){
int count = 0;
        for (API api : apis) {
            if (api.findRooms(price, persons, city, hotel) != null) count++;
        }//считаю кол-во комнат
        Room[] res = new Room[count];// создаю массив для них
}

and then you need to go through the array of rooms (findRooms) and get these rooms,
I can’t think of it, explain where my snag is

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question