• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Write a method that can be called, that will initialize the seating plan.

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having a few problems and not sure how to make it work

1. the program should not be initializing the seating plan when it is declared. I need to write a method that
I can call that will initialize the seating plan to all seats available. Then when I loop to start over,
I can just call that method to reset the seating plan.

2. Also, when the user selects E or F the program should tell them the valid rows for that ticket type to select from.
And when the user selects smoking or nonsmoking it should tell them the valid rows.

I appreciate all the help I can get thank you!

 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


1. the program should not be initializing the seating plan when it is declared. I need to write a method that
I can call that will initialize the seating plan to all seats available. Then when I loop to start over,
I can just call that method to reset the seating plan.

2. Also, when the user selects E or F the program should tell them the valid rows for that ticket type to select from.
And when the user selects smoking or nonsmoking it should tell them the valid rows.



Let's see what you've attempted for these two problems first.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok well I think I've almost got the first part of it down but It is printing out 42 instead of char being *. I think I need to declare a char or something... not really sure but this is what I have so far.

 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I just figured it out...
 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may have figured out how to print a whole bunch of * but since I put that code into my program i get a cannot find symbol. I feel like this question belongs in the beginning java area.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dustin Schreader wrote:I may have figured out how to print a whole bunch of * but since I put that code into my program i get a cannot find symbol.


You're running into a scope issue in that your seatNumber variable has been declared within the main method and so is only visible from within this method. If you want it visible inside of other methods, either pass it as a parameter to the method or declare it in the class to give it class scope.

I feel like this question belongs in the beginning java area.


Agree.

Another thing you must do is be sure to enclose all blocks in curly braces even if it's an if block with only one line of code. Doing this will save your tail in the future, trust me. Also watch out for pesky semi-colons at the end of the boolean condition of an if block, while loop, for loop and the like as this will short-circuit the loop, i.e.,

 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great thank you for the help, I did get it working now.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dustin Schreader wrote:Great thank you for the help, I did get it working now.



Yeah! Congrats!
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dustin Schreader wrote:I feel like this question belongs in the beginning java area.


Well, since Pete agrees, how can I disagree?
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You realise that chars like 'a' and 'A' are not letters, but numbers? You can do arithmetic on them. You can try printing 'a' % 0x20 - 1 as a way of converting 'a' to 0. Remember 0x20 is 32 in decimal. That might get rid of those awkward looking switch blocks. It will fall down, however, when you get to 9 seats width and you go from H to J missing out I!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic