Re: Need Help getting kinks out
From: Sebastian Scheid (mynewsgroup_at_web.de)
Date: 12/13/04
- Next message: nitro2k01: "Re: How Reliable Is File.deleteOnExit()?"
- Previous message: Hal Vaughan: "How Reliable Is File.deleteOnExit()?"
- In reply to: CappaKia: "Need Help getting kinks out"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: nitro2k01: "Re: How Reliable Is File.deleteOnExit()?"
- Previous message: Hal Vaughan: "How Reliable Is File.deleteOnExit()?"
- In reply to: CappaKia: "Need Help getting kinks out"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|