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

2021/5/19

Counters not working

1
2
3
4
5
HELP HELP

2021/5/19

#
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import javax.swing.JOptionPane; public class Login extends Actor { public void act() { if (Greenfoot.mouseClicked(this)) { String username1 = JOptionPane.showInputDialog("Please enter your username."); String password1 = JOptionPane.showInputDialog("Please enter your password."); if(username1.equals(uname1 || uname3 || uname5 || uname7) & password1.equals(pword1 || pword3 || pword5 || pword7)) { Greenfoot.setWorld(new Level12()); } else Greenfoot.setWorld(new Level13()); } } }
HELP HELP

2021/5/19

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import javax.swing.JOptionPane;

public class Login extends Actor
{
    public void act() 
    {
        if (Greenfoot.mouseClicked(this))
        {
        String username1 = JOptionPane.showInputDialog("Please enter your username.");    
        String password1 = JOptionPane.showInputDialog("Please enter your password.");
        if(username1.equals(uname1 || uname3 || uname5 || uname7) & password1.equals(pword1 || pword3 || pword5 || pword7))
        {
            Greenfoot.setWorld(new Level12()); 
        }
        else Greenfoot.setWorld(new Level13()); 
        } 
    }    
}
HELP HELP

2021/5/19

#
HERE IT IS. IT DOESNT WORK AND THE LOGIN CLASS IS THE ONE WITH THE ERROR
HELP HELP

2021/5/19

#
if(username1.equals(uname1 || uname3 || uname5 || uname7) & password1.equals(pword1 || pword3 || pword5 || pword7))
HELP HELP

2021/5/19

#
THAT LINE IS THE ONES WITH THE ERRORS I THINK
HELP HELP

2021/5/19

#
IT SAYS THE VARIABLES CANNOT BE FOUND ON THAT LINE #
HELP HELP

2021/5/19

#
PLEASE LET ME KNOW WHAT TO CHANGE
HELP HELP

2021/5/19

#
HELLO SOMEONE PLEASE HELP ITS EXTREAMLY IMPORTANT! I CANT GO TO SLEEP WITHOUT IT!
danpost danpost

2021/5/19

#
The compiler has no idea what all uname# and pword# are. These variables have not been declared and assigned values.
RcCookie RcCookie

2021/5/19

#
Also you can’t „or“ two strings (uname1 || uname2); you can only OR booleans
RcCookie RcCookie

2021/5/19

#
Just aside I wanted to let you know that any java swing stuff ain’t work online, if that’s something you want to be doing
HELP HELP

2021/5/19

#
So what do i do Dan? I really need this to work soon. So sorry. please talk back soon.
HELP HELP

2021/5/19

#
I’m not trolling i haven’t slept in 2 days. And i kind of really need this working. So instead of uname1|| uname2 what code should i right instead?
danpost danpost

2021/5/19

#
RcCookie wrote...
Also you can’t „or“ two strings (uname1 || uname2); you can only OR booleans
They probably do refer to strings, but I have seen plenty of "weird" code that I was not going to presume as much (on the off chance they were booleans).
danpost danpost

2021/5/19

#
HELP wrote...
So what do i do Dan? I really need this to work soon. So sorry. please talk back soon.
Do each one individually. Short example:
if (username1.equals(uname1) || username1.equals(uname2))
There are more replies on the next page.
1
2
3
4
5