Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Array Problem....sort of Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array Problem....sort of" Watch "Array Problem....sort of" New topic
Author

Array Problem....sort of

Ben Kopel
Greenhorn

Joined: Feb 25, 2007
Posts: 1
Howdy Ranchers...

This being one of my first Java projects, it's got me stumped. Basically, the project is this: An airline has 10 seats (First class 1-5, Economy 6-10). The user is prompted to enter 1 (for First) or 2 (for Economy). Once First or Economy is full, the user should be told it is full and asked whether it's ok to be seated in the non-full section. When both sections are full, it should display "Next flight leaves in 3..." message.

I've got most of it, but cannot figure out how to display and prompt the user with the message that one section is full, would they like to sit in the other (firstFullChoice).

Also, I was getting the Plane full message (Next flight leaves in 3...) before, but for some reason, that's not appearing anymore.

Any suggestions are very much welcome.




EDIT by mw: Added much-needed Code Tags.
[ February 25, 2007: Message edited by: marc weber ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

Look at the flow of execution. Suppose the user asks for first class. If there's a seat available in first class (if firstClassseat != -1), it assigns it. But if not (else), it should ask the user if economy is okay. Instead, this code is just going ahead and assigning economy without asking. This is where you might call firstFullChoice.

Paying more attention to flow should get you past the main issue, although there are still some bugs with seat assignments. For example, in firstFullChoice, when the plane is full, it keeps assigning seat#0. Do you see why?

Also, it doesn't look like it's being used, but the firstClassFull method has an error in the for statement -- it should be i<5, rather than i>5.)
[ February 25, 2007: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
Don't get me started about those stupid light bulbs.
 
subject: Array Problem....sort of