Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Illegal start of type

 
Dustin Schreader
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to add a new method initializeArray and it is supposed to make an array of 13 by 6 of '*' Now I'm getting a illegal start of type on the method right underneath.
 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry ignore the above code, the problem I'm having is that instead of getting an array of * i'm getting an array of 00.
I know it must be out of the scope but i'm not sure where.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a lot of code to look at to figure out one specific issue--it might make more sense to show just the code relevant to your specific issue (and header comments never need to be posted; they only obfuscate real issues...) Make it easy for us! :)
 
Dustin Schreader
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry i'm having a problem with the initializeArray method not giving out * like I want to and printMatrix method is not seeing initializeArray
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you call initializeArray?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if everything is static, why do you still pass seatNumber around?
 
Dustin Schreader
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I probably didn't call initializeArray I don't know how to call methods I guess. I don't know why I pass seatNumber around, should I change all the seatNumber to matrix? Sorry I'm pretty new to java.
 
Vineet Kakati
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to compile your your code and there were no compilation errors.
If there is some logical error please elaborate on it.

 
Dustin Schreader
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does compile nicely but It isn't working the way I want it to. I want it to print out an array of asteriks * so it will look something like this

and so on but i'm gettin something that looks like this

printMatrix doesn't recognize initializeArray and I think
its because I didn't call a method or something
or it may have to do with the scope?
 
Vineet Kakati
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not giving a call to function initializeArray() anywhere;
call function initializeArray() in main before do while loop;



Also I noticed that your code works only once i.e after allotting 1 seat the program terminates.
I suppose you want to allot more than 1 seat;

I suggest taking user input to decide whether to break 'do while' loop or not.
 
Dustin Schreader
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose I should also add that I am trying to get this initializeArray method to work so that after the program takes all the input from the user I would like to have a loop that lets the user enter another seat selection by restarting the program or reset the seating chart by calling the method initializeArray. Once I figure out how to call a method that is.
 
Dustin Schreader
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds like an awesome idea but i've been searching google for most of the night to figure out a way to call a method. I'm new to Java could you give me an example of a way to call this method or a nudge in the right direction for what the code should look like to call a method?

WOW that worked very well and it was sooo simple I feel bad for having a headache so easily
now I only need to look at a way to make this thing loop the way I want it to... or how the user wants it to.
Thank you
 
Vineet Kakati
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
simply write


immediately after


That should do the trick.
 
Vineet Kakati
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make program loop as per user input simply change your outermost 'do while' loop.

1:Put the 3 function calls printMatrix ,chooseSeat, printMatrix(1,13) inside 'do while' loop;

2:Then ask user if he wants to allot another seat.

Refer the code snippet below
 
Dustin Schreader
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked out great! But lets say that I wanted to either end the program, restart it, or reset the seating chart, in order to reset the seating chart would I have to call initializeArray from the main method?
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic