7 Replies - 2864 Views - Last Post: 28 December 2012 - 08:23 AM Rate Topic: -----

#1 extremeblueness  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 186
  • Joined: 22-October 12

Illegal Start of Type Compile-Time Error

Posted 27 December 2012 - 05:26 PM

I'm getting the most confounding error. The first command prompt error (caught by holding the scroll bar in the middle of compiling) reads

Quote

SaveChristmas.java:27026: error: illegal start of expression
public void moveUp()


The carrot's pointing to the 'p'. I have no idea why this is happening, as this is the first time I've ever had a keyword pointed out as the error. I already checked for parenthesis in the code immediately above it. There are no other methods with the same name. The word void is also being called out, and moveUp is being called out for semi-colons. Every method after this is also being called out in the same exact way.

Here's the surrounding code, starting at line 26963:
        else if (initialLocation.contains("b"))
        {
            if (initialLocation.contains("1"))
            {
                currentLocation = "c1";
            }
            else if (initialLocation.contains("2"))
            {
                currentLocation = "c2";
            }
            else if (initialLocation.contains("3"))
            {
                currentLocation = "c3";
            }
            else if (initialLocation.contains("4"))
            {
                currentLocation = "c4";
            }
            else if (initialLocation.contains("5"))
            {
                currentLocation = "c5";
            }
            else if (initialLocation.contains("6"))
            {
                currentLocation = "c6";
            }
            else if (initialLocation.contains("7"))
            {
                currentLocation = "c7";
            }
        }
        else if (initialLocation.contains("a"))
        {
            if (initialLocation.contains("1"))
            {
                currentLocation = "b1";
            }
            else if (initialLocation.contains("2"))
            {
                currentLocation = "b2";
            }
            else if (initialLocation.contains("3"))
            {
                currentLocation = "b3";
            }
            else if (initialLocation.contains("4"))
            {
                currentLocation = "b4";
            }
            else if (initialLocation.contains("5"))
            {
                currentLocation = "b5";
            }
            else if (initialLocation.contains("6"))
            {
                currentLocation = "b6";
            }
            else if (initialLocation.contains("7"))
            {
                currentLocation = "b7";
            }
        }
    }
    public void moveUp()
    {
        upString();
        if (largeLocation.equals(initialLargeLocation))
        {
            paintMovement();
            monsterMove();
            y++;
        }
        else
        {
            paintLargeMovement();
            objectRandomization();
            largeY++;
            initialLargeLocation = largeLocation;
        }
        bearAppear();
        initialLocation = currentLocation;
        
        if (currentLocation.equals(monsterALocation) || currentLocation.equals(monsterBLocation) || currentLocation.equals(monsterCLocation))
        {
            showStatus("You are attacked by a walrus!");
        }
    }


Is This A Good Question/Topic? 0
  • +

Replies To: Illegal Start of Type Compile-Time Error

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2013
  • View blog
  • Posts: 3,037
  • Joined: 21-June 11

Re: Illegal Start of Type Compile-Time Error

Posted 27 December 2012 - 05:37 PM

I think your first instinct was right. With that error message, you almost certainly have an unclosed opening brace in there somewhere. I don't see it in the code you've posted, so it's probably somewhere further up.

PS: Might I suggest splitting your code into multiple files? 27k+ lines in one file is a bit much in my opinion.
Was This Post Helpful? 2
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2879
  • View blog
  • Posts: 9,552
  • Joined: 12-December 12

Re: Illegal Start of Type Compile-Time Error

Posted 27 December 2012 - 06:03 PM

FYI you could use code like the following:

for (i=1; i <= 7; i++) {
    if (initialLocation.contains(Integer.toString(i))) {
        currentLocation = "c" + i;
        break;
    }
}


BTW How fast do walruses move? I might be able to run away!?

This post has been edited by andrewsw: 27 December 2012 - 06:06 PM

Was This Post Helpful? 0
  • +
  • -

#4 extremeblueness  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 186
  • Joined: 22-October 12

Re: Illegal Start of Type Compile-Time Error

Posted 27 December 2012 - 06:45 PM

Found my error. It was an unclosed opening curly brace near the top of the previous method.

@andrew its an RPG without flee capabilities.

@sepp its a Swing Applet, and I want putting it online to be as simple as possible. In other words, no more than one class. BTW, its 250,000 lines of code.
Was This Post Helpful? -1
  • +
  • -

#5 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2013
  • View blog
  • Posts: 3,037
  • Joined: 21-June 11

Re: Illegal Start of Type Compile-Time Error

Posted 27 December 2012 - 06:46 PM

That's what JARs are for.
Was This Post Helpful? 1
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: Illegal Start of Type Compile-Time Error

Posted 27 December 2012 - 10:20 PM

This is ridiculous !!!!
A class with 26963 lines !!!

Just to check that ridiculous code what about
currentLocation = "c" + initialLocation.toString(); or something like that

This code is a shame :v:
Was This Post Helpful? 0
  • +
  • -

#7 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7293
  • View blog
  • Posts: 12,103
  • Joined: 19-March 11

Re: Illegal Start of Type Compile-Time Error

Posted 27 December 2012 - 10:57 PM

View Postextremeblueness, on 27 December 2012 - 08:45 PM, said:

Found my error. It was an unclosed opening curly brace near the top of the previous method.

@andrew its an RPG without flee capabilities.

@sepp its a Swing Applet, and I want putting it online to be as simple as possible. In other words, no more than one class. BTW, its 250,000 lines of code.



I guarantee this is not the best way to write or to deploy this code. I'm impressed by your fortitude in cranking out a quarter of a million lines of code, but you need to make this simpler and you need to make it shorter. Refactoring will help with that, and so will using objects. But you can start by eliminating duplication - I can already see that you're using a huge amount of duplication. Let's just look at the code we've seen already.
    else if (initialLocation.contains("b"))
02	    {
03	        if (initialLocation.contains("1"))
04	        {
05	            currentLocation = "c1";
06	        }
07	        else if (initialLocation.contains("2"))
08	        {
09	            currentLocation = "c2";

...
31	    }
32	    else if (initialLocation.contains("a"))
33	    {
34	        if (initialLocation.contains("1"))
35	        {
36	            currentLocation = "b1";
37	        }
....



So a location is a String of the form xy, where x is a character and x is a digit. Fine.


char x =initialLocation.charAt(0);
char y = initialLocation.charAt(1);



Now they're integers. Life would be a bit easier for you if they were both digits, but we'll go with this for now.
int x_loc= (int)x-'a'; 
int y_loc= (int)y-'0';



Okay, now you have two integers. Four lines to do that, you can make that a method. So now to move right, add one to x. To move down, subtract one from y (or maybe add one to y - depends where 0,0 is located).
Once you've dealt with the location, change them back to your grid coordinates by the inverse procedure.

I'm guessing that change takes about 28^2 lines of code out of your codebase, replacing them with about 30. You can probably get rid of a lot of lines like that.
Was This Post Helpful? 2
  • +
  • -

#8 extremeblueness  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 186
  • Joined: 22-October 12

Re: Illegal Start of Type Compile-Time Error

Posted 28 December 2012 - 08:23 AM

I'm planning on using all of your advice for future reference. But not now because going back through that quarter million lines of code gives me shudders.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1