Sorry if this has already been stated elsewhere. Wasn't able to find it!
Right, im designing a small reservation system via java on BLUEJ. Iv so far done the following coding.
public void addBooking(Client client, int dayNumber, int numberOfDays)
{
for(int index = dayNumber; index < bookableDays.length -1 ; index++){
bookableDays[index-1] = client;
if(index > numberOfDays -1){
bookableDays[index] = null;
}
}
The dayNumber is assigned as the index element in the array, so the user can reserve any day (array element) which is less than 30 (array declared as 30 in the constructor). A client would like to book a property e.g booking on the 5th (passed on via dayNumber & stored in element 4) and staying for seven days (passed on via numberOfDays paramter so the clients details should increment from element 4 up to 11).
However, when i enter the numberOfDays (in the parameter of the method) the increment only stops up to the element which is the same value of the numberOfDays -1, hence, if i enter 10, the value stores up to element 9 (which I do not want it to do).
Thanks,
Side21
This post has been edited by side21: 11 January 2011 - 01:22 PM

New Topic/Question
Reply




MultiQuote




|