.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
';' expected - Java
Old
  (#1)
Zacker
Project Leader, Lead Level Designer, Waypointer
 
Status: Offline
Posts: 337
Join Date: Mar 2004
Location: Denmark
Default ';' expected - Java - 04-06-2004

I know there arent many java coders in here, but I hope someone can help my anyway.

The compiler gives me this error with a "^" below the last bracket:

';' expected
stats_sum = styrke + intelligens + liv.liv()/10);



This is how the lines around look like:
//Tjek om stats er fair
public void stats()
{
double stats_sum;
stats_sum = styrke + intelligens + liv.liv()/10);
if(stats_sum!=30)
{
System.out.println("");
System.out.println("Intern programfejl - Stats for racen "
+ race + " er ikke fair");
System.out.println("");
}
}

The liv object gets initialized here:
//Liv
//Opret et objekt af klassen Liv
Liv liv = new Liv();


The liv method/function is here:
//Justerer eller returnerer spillerens liv
public int liv(int a)
{
if(a!=0)
{
//Giver spilleren a mere i liv, hvis a ikke er 0
liv = liv + a;
System.out.println("Du har nu " + liv + " i liv");
}
else
{
//Returnerer værdien af liv til den kaldende funktion
return liv;
}

}

Last edited by Zacker; 04-06-2004 at 18:52..
  
Reply With Quote
Re: ';' expected - Java
Old
  (#2)
MusicMan
Member
 
Status: Offline
Posts: 236
Join Date: Feb 2004
Default Re: ';' expected - Java - 04-06-2004

Hey, fellow Dane

*couldn't resist*

Last edited by MusicMan; 04-06-2004 at 18:52..
  
Reply With Quote
Re: ';' expected - Java
Old
  (#3)
Zacker
Project Leader, Lead Level Designer, Waypointer
 
Status: Offline
Posts: 337
Join Date: Mar 2004
Location: Denmark
Default Re: ';' expected - Java - 04-06-2004

I am indeed danish!
  
Reply With Quote
Re: ';' expected - Java
Old
  (#4)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: ';' expected - Java - 04-06-2004

Ive never seen any other java code except this but shouldn't
Code:
      stats_sum = styrke + intelligens + liv.liv()/10);
be
Code:
      stats_sum = styrke + intelligens + liv.liv()/10;
I'm just guessing...
  
Reply With Quote
Re: ';' expected - Java
Old
  (#5)
MusicMan
Member
 
Status: Offline
Posts: 236
Join Date: Feb 2004
Default Re: ';' expected - Java - 04-06-2004

Don't you mean:

stats_sum = styrke + intelligens + Liv.liv()/10); //notice the capital L in class Liv

because there doesn't seem to be a difference between your two code snippets.

Last edited by MusicMan; 04-06-2004 at 19:05..
  
Reply With Quote
Re: ';' expected - Java
Old
  (#6)
Zacker
Project Leader, Lead Level Designer, Waypointer
 
Status: Offline
Posts: 337
Join Date: Mar 2004
Location: Denmark
Default Re: ';' expected - Java - 04-06-2004

You found it Rick, thanks for the quick reply!

MusicMan, nope the capital is not needed. I define the Liv class to be liv here:
Liv liv = new Liv();
1. word is variable type
2. word is variable name
3. word is for a new object
4. word is class name
  
Reply With Quote
Re: ';' expected - Java
Old
  (#7)
MusicMan
Member
 
Status: Offline
Posts: 236
Join Date: Feb 2004
Default Re: ';' expected - Java - 04-06-2004

oh, now I see the difference you should not have the paranthesis at the end.
  
Reply With Quote
Re: ';' expected - Java
Old
  (#8)
Huntkillaz
Member
 
Huntkillaz's Avatar
 
Status: Offline
Posts: 594
Join Date: Mar 2004
Location: Middle Earth (New Zealand)
Default Re: ';' expected - Java - 09-06-2004

java roxor

yeah downside about the compiler is it's not very accurate as to giving u whats exactly wrong....but basically the error is somewhere on that line...or rarely else where in code that calls the line

what is it ur trying to do with that code if u don't mind me asking


●_•
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com