This site requires JavaScript, please enable it in your browser!
Greenfoot back
sophiaking
sophiaking wrote ...

2015/3/6

Errors I'm not sure how to correct

sophiaking sophiaking

2015/3/6

#
quote=sophiaking]
public void isDead()
    {
        String input = JOptionPane.showInputDialog ("Do you wish to continue?");

        if ( [b]P1Counter.getValue()[/b] == 0  && input.equals ("yes") ) 
        {
            
            World myWorld = getWorld();
            myWorld.removeObject(this);
            play1Option2 p2= new play1Option2(cpcounter);
            myWorld.addObject(p2, 519, 409);
            Player1Option2AttackButton pb1 = new Player1Option2AttackButton(cpcounter);
            myWorld.addObject(pb1, 271, 390);

        } // spawns a new player for the computer to battle

        if ( input.equals("no") &&  CPCounter.getValue() == 0 )
        {
            World myWorld = getWorld();
            GameOver gameover = new GameOver();
            myWorld.addObject(gameover, myWorld.getWidth()/2 , myWorld.getHeight()/2);

          
        }// allows game over screen to appear
i am not sure how to fix the bolded error
danpost danpost

2015/3/6

#
Need more background on your fields (P1Counter and CPCounter -- how declared and where) and a full error message (copy/pasting in entirety).
sophiaking sophiaking

2015/3/8

#
 public void isDead(CPCounter cpcounter,  P1Counter counter)
    {
        String input = JOptionPane.showInputDialog ("Do you wish to continue?");

        if ( P1Counter.getValue(counter) == 0  && input.equals ("yes") ) 
        {
            
            World myWorld = getWorld();
            myWorld.removeObject(this);
            play1Option2 p2= new play1Option2(cpcounter);
            myWorld.addObject(p2, 519, 409);
            Player1Option2AttackButton pb1 = new Player1Option2AttackButton(cpcounter);
            myWorld.addObject(pb1, 271, 390);

        } // spawns a new player for the computer to battle

        if (   CPCounter.getValue(cpcounter) == 0 && input.equals("no") )
        {
            World myWorld = getWorld();
            GameOver gameover = new GameOver();
            myWorld.addObject(gameover, myWorld.getWidth()/2 , myWorld.getHeight()/2);

          
        }// allows game over screen to appear
    }// creates the next version of the player 1 or the game ovr screen 

    public player1option1(CPCounter cpcounter,  P1Counter counter)
    {
        this.cpcounter = cpcounter;
        this.counter = counter;
        // this.counter = counter;
        GreenfootImage image = getImage();

        image.scale(200,300);
        setImage(image);
the error occurs at getValue(); the reason says actual and formal arugements differ in length
danpost danpost

2015/3/8

#
You probably want to use 'counter.getValue()', not 'P1Counter.getValue(counter)'. The same kind of change should be done on line 17. The error was stating that you cannot supply any arguments (values or expressions within the round braces immediately following the method name) in a 'getValue' method call because the method is not declared to accept any values (no declared parameters).
You need to login to post a reply.