vendredi 11 mai 2018

Do something if all the criteria are true

In my study I have to program a system that get struct of Apartments that contain: apartment code, price, number of rooms and etc.

In other part of the system when the List of apartments are including apartments, I have to build a function that print out to screen all of the apartments that meet all the requirements the user asking for. for example, for this command from user: "PRINT maxRooms 5 Price 20000" the function will scan the List of apartments and print only the apartments that have maximum 5 rooms and their price is less than 20000.

There is simple way to check if the user wrote a command with criteria, check it and go for the next criteria? or the only way is to write it with if-else statements?

I've initialize those local variables in -1 and now I'm in the stage that if my local variable different from -1 the user asked for this filter. For the sake of simplicity lets assume that we have only three criteria: price, maximum number of rooms, minimum number of rooms.

Aucun commentaire:

Enregistrer un commentaire