-1

My teacher is away for 2 days and I'm stuck. I keep getting these two errors when I try to run the main file

U:\Computer science\AP Computer Science\10.boolean\lab10_boolean\PassRunner.java:8: error: class Lab10a is public, should be declared in a file named Lab10a.java

and

U:\Computer science\AP Computer Science\10.boolean\lab10_boolean\PassRunner.java:12: error: constructor PasswordCheck in class PasswordCheck cannot be applied to given types;

The code in my main file is

import static java.lang.System.*;

public class Lab10a
{
    public static void main( String args[] )
    {
        PasswordCheck test = new PasswordCheck();
        test.check();
    }
}

and is named PassRunner.java

The code in my other class file is

import java.util.Scanner;
import static java.lang.System.*;

class PasswordCheck
{
    private String password = "mchammergohammer";

    public PasswordCheck(String word)
    {
        word = "";
    }

    public void check()
    {
        Scanner keyboard = new Scanner(System.in);
        int x = 0;
        String tmpPas = "";

        do{
            out.println("THIS LEVEL OF SECURITY REQURES A PASSWORD");
            tmpPas = keyboard.next();
            if( tmpPas == password )
                out.println("ACCESS GRANTED");
            else
                x++;
                out.println("ACCESS DENIED");
        }while( tmpPas != password || x <= 10);
        if( x >= 10);
            out.println( "YOU HAVE REACHED THE MINIMUM AMOUNT OF ATTEMPTS");

    }

    public void setPass()
    {
        out.println("Enter your current password: ");
    }
}

and it is named PassWordCheck.java

I've looked at other code and I still don't understand, as I am still new to coding.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Emmanuel
  • 11
  • 1
  • 6

1 Answers1

0

Just move your Lab10a class definition to a separate java file named Lab10a.java and import it in the other classes the use it.

Webert Lima
  • 13,197
  • 1
  • 11
  • 24