java - Why isn't my method noticing what is being help by a spot in a 2d array? -


so writing program allow book seat on flight. asks user how many rows available, makes 2d array 4 columns , how ever many rows user specifies. program prompts user choose how man seats wants , row , column wants seats be. change value of position in array form "-" "x". works beautifuly, i'm running issues when trying use method cancel reserved seating. have props user, if wants cancel seat , how many, row , column wants cancle. checks see if spot in array has value of "-" or "x" if has "-" displays message saying need input seat reserved , if has "x" changes "-" show open. reason if put in position take or has "x" value says there isn't, did wrong?

here code:

this cancle method

public void cancleseat(string[][] sc, string can, int c, int r, int seats, int an){     fillarray(sc);     if (can.equals("no")){         system.out.println("ok, no cancelations you!");     }     else if (can.equals("yes")){         system.out.println("how many seats cancel?");         = scanner.nextint();         (int = 0; < an; i++){             system.out.println("what row seat in cancle?");             r = scanner.nextint();             r = r - 1;             system.out.println("what colum seat in cancle?");             c = scanner.nextint();             c = c -1;             if (sc[r][c].equals("-")){                 system.out.println("that seat isn't researved pleas pick different seat");                 system.out.println("what row seat in cancle?");                 r = scanner.nextint();                 r = r - 1;                 system.out.println("what colum seat in cancle?");                 c = scanner.nextint();                 c = c - 1;             }             else if (sc[r][c].equals("x") || sc[r][c].equals("x")){                 sc[r][c] = "-";             }         }     } } 

and using call in driver class.

system.out.println("would canlce reservations?"); cancle = scanner.next(); seeting cancler = new seeting(numseatsbooking, row, colum, cancle, openseats, answer); cancler.cancleseat(seetingchart, cancle, colum, row, numseatsbooking, answer); 

any appreciated! thanks


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -