Re: Need Help getting kinks out

From: Sebastian Scheid (mynewsgroup_at_web.de)
Date: 12/13/04


Date: Mon, 13 Dec 2004 19:07:53 +0100


"CappaKia" <HowaboutNO@spam.com> schrieb im Newsbeitrag
news:1fde8d6120781030991b9ea3497db061@localhost.talkaboutprogramming.com...
> I'm almost finished with my project but I am getting error messages when I
> compile. Can you help??

The compiler presents the line with the error. So please have a look at
these lines before posting lots of code!
Some given lines may not contain errors. Often the compiler is confused by
missing paranthesis.

>
> Here are the error messages that I am getting:
> \My Documents\CS151\TicketDriver.java:121: '}' expected
> }//end class TicketDriver
> ^
> \Ticket.java:83: ')' expected
> (Character.toUpperCase(this.response)==
> (Character.toUpperCase(otherTicket.response))

Ok, let's have a look at line 83.

>
> ^
> \Ticket.java:90: ')' expected
> }
> ^
> \Ticket.java:91: illegal start of expression
> }//end equals
> ^
> 4 errors
>
> Tool completed with exit code 1
>
>
>
>
>
>
> Here is a copy of my program:
>

[snip]

>
> //*********************************************************************************************
> //This method checks to see if any of the car drivers have the same
> information
>
> public boolean equals (Ticket otherTicket)
> {
>
> if ((this.name.equalsIgnoreCase(otherTicket.name)) &&
> (this.speed == (otherTicket.speed))&&
> (this.speedLimit == (otherTicket.speedLimit)) &&
> (Character.toUpperCase(this.response)==
> (Character.toUpperCase(otherTicket.response))
> {
> return true;
> }
> else
> {
> return false;
> }
> }//end equals

There are may superflous parentheses in this conditional statement. This
does not only confuse the compiler but readers (and the author) too. I think
you should delete the paranthesis before the last "Character" and add one
after "otherTicket.response))":

if ((this.name.equalsIgnoreCase(otherTicket.name)) &&
     (this.speed == (otherTicket.speed))&&
     (this.speedLimit == (otherTicket.speedLimit)) &&
     (Character.toUpperCase(this.response)==
      Character.toUpperCase(otherTicket.response)))
 {

I hope this works.

btw I prefer:

public boolean equals (Ticket otherTicket) {
    return this.name.equalsIgnoreCase(otherTicket.name) &&
        this.speed == (otherTicket.speed)&&
        this.speedLimit == (otherTicket.speedLimit) &&
        Character.toUpperCase(this.response)==Character.toUpperCase(otherTicket.response);
}

Perhaps there are more errors in the rest of the code.

Regards
Sebastian



Relevant Pages

  • Re: Capturing error line on exception (SWI)
    ... > print_message/2 to catch and print error messages. ... > prevent the compiler from stopping after the first error. ... > an explicitely passed input stream to avoid trouble with directives that ... > may modify the current input stream and do really weird things. ...
    (comp.lang.prolog)
  • C Compiler Errors (For Real).
    ... These are some of the error messages produced by Apple's MPW C ... afternoon and decompiled the String resources for the compiler.) ... "Can't cast a void type to type void (because the ANSI spec. ... "This label is the target of a goto from outside of the block containing this ...
    (rec.humor.funny.reruns)
  • Re: The Decline of C/C++, the rise of X
    ... >> Jim points out later, and poorer error messages on a syntax error, as ... > clearly identify the position of an error is a feature of a compiler ...
    (comp.programming)
  • Re: The Decline of C/C++, the rise of X
    ... >> Jim points out later, and poorer error messages on a syntax error, as ... > clearly identify the position of an error is a feature of a compiler ...
    (comp.programming)
  • Re: The Decline of C/C++, the rise of X
    ... >> Jim points out later, and poorer error messages on a syntax error, as ... > clearly identify the position of an error is a feature of a compiler ...
    (comp.programming)