Results 1 to 2 of 2
  1. #1
    javagangster is offline Member
    Join Date
    Apr 2011
    Posts
    1
    Rep Power
    0

    Default Java boolean problem

    Hello,

    I'm new to java and this forum and I stumbled on this problem. It would be great if somebody could help me with this!:confused:

    BTW i'm dutch and therefore the commands are in Dutch.

    down here is my java logo program (and the error is under my program):

    /*
    * @(#)BalUitd.java 11/03/15
    *
    * JavaLogo Project
    *
    */
    import logotekenap.*;


    public class BalUitd extends TekenApplet
    {
    double xverander;
    double yverander;
    double xstap;
    double ystap;
    int teller;

    public void initialiseer()
    {
    maakTraceMogelijk();
    maakAnimatieMogelijk();
    xstap=0;
    ystap=0;
    xverander=1;
    yverander=0.5;
    }

    public void tekenprogramma()
    {
    bal(xstap, ystap, "rood");
    }

    public void bal(double xstap, double ystap, String kleur)
    {
    pen.vooruit(ystap+yverander);
    pen.rechts(90);
    pen.vooruit(xstap+xverander);
    pen.links(90);
    pen.vulAan(kleur);
    pen.vooruit((360*0.5)/(2*Math.PI));
    pen.rechts(90);
    int teller;
    teller =0;
    while (teller < 360)
    {
    pen.vooruit(0.4);
    pen.rechts(1);
    teller=teller+1;
    }
    pen.vulUit();
    }

    public void animatie(double xstap, double ystap, double xverander, double yverander)
    {
    while(animatieLopend())
    {

    if(xstap=300)
    {
    xverander=-xverander;
    }

    else if(xstap=-300)
    {
    xverander=-xverander;
    }

    else if(ystap=-300)
    {
    yverander=-yverander;
    }

    else if(ystap=300)
    {
    yverander=-yverander;
    }
    }
    tekenOpnieuw();
    }

    }
    ERROR: (They refer to the Animatie segment)

    --------------------Configuration: BalUitd - j2sdk1.4.2_05 <Default> - <Default>--------------------
    H:\MyProjects\BalUitd\BalUitd.java:133: incompatible types
    found : double
    required: boolean
    if(xstap=300)
    ^
    H:\MyProjects\BalUitd\BalUitd.java:138: incompatible types
    found : double
    required: boolean
    else if(xstap=-300)
    ^
    H:\MyProjects\BalUitd\BalUitd.java:143: incompatible types
    found : double
    required: boolean
    else if(ystap=-300)
    ^
    H:\MyProjects\BalUitd\BalUitd.java:148: incompatible types
    found : double
    required: boolean
    else if(ystap=300)
    ^
    4 errors

    Process completed.
    THANKS!
    :):)

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    The comparison for equality operator is == (two equal signs); you used the assignment operator = (one equal sign).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. problem on expressing a boolean method
    By b.m in forum New To Java
    Replies: 9
    Last Post: 12-12-2010, 07:17 PM
  2. Replies: 2
    Last Post: 10-15-2010, 06:09 AM
  3. boolean condition creating problem
    By Basit781 in forum CLDC and MIDP
    Replies: 1
    Last Post: 05-25-2010, 08:57 AM
  4. use boolean as 0 or 1
    By joost_m in forum New To Java
    Replies: 10
    Last Post: 04-13-2010, 12:22 PM
  5. [SOLVED] boolean method problem
    By shadowblade19 in forum New To Java
    Replies: 6
    Last Post: 11-30-2008, 03:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •