Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes Beginner needs help!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Beginner needs help!!" Watch "Beginner needs help!!" New topic

Beginner needs help!!

Josh Wetzel

Joined: Sep 30, 2000
Posts: 3
I am trying to write a class (Login) for a login/password program but I am getting a "tool completed with exit code 2 error" message when I compile the program. The LoginTest class was already written for me, all I am supposed to do is write the Login class. Can anyone help me see what I'm doing wrong?
This is the LoginTest class.
import corejava.*;
public class LoginTest {

public static void main(String[] args) {
int m=3,n=2;
int x = 0;
Login u = new Login(); //declare and instanciate the object u
//default constuctor = Login (same name as class)
String inlog;
String inpass;
boolean y = false;
for (int i = 0; i<m; i++) {<br /> inlog = Console.readLine("Please enter a login id:");<br /> x = u.getUid(inlog);<br /> if (x > 0) break;
if (x == 0) System.out.println("SORRY!");
else {
for (int i =0; i<n;i++) {<br /> inpass = Console.readLine("Please enter your password:");<br /> if (u.testPwd(x,inpass)) {<br /> y=true;<br /> break;<br /> }<br /> }<br /> if (y == false) System.out.println("SORRY "+u.getNick(x)+"!");<br /> else System.out.println("You are logged in "+u.getNick(x)+"!");<br /> }<br /> <br /> }<br /> }<br /> This is the class I'm trying to write called Login<br /> public class Login {<br /> String nick;<br /> Login u = new Login(inlog, inpass, nick); //Calls the constructor function Login<br /> Login user[0] = new Login("jim", "jimpass", "jimbo");<br /> Login user[1] = new Login("robert","robertpass","bob");<br /> Login user[2] = new Login("justin", "justinpass", "justincase");<br /> public int getUid(String loginid) {<br /> String user;<br /> user = loginid; //returns a uid>0 if valid loginid
if (user[i].equals(loginid)) //returns a 0 if invalid loginid
return 1;
else return 0;
public boolean testPwd(int uid,String inpass) { //returns true if valid
if (user[i].equals(inpass)) //password for a given uid,
return true;//returns false if not
else return false;

public String getNick(int uid) //returns Nickname for a given uid
{return Nick;} //accessor method

Thanks in advance!
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
what does you compile command look like? (for example, are you using any special switches? Are you using javac or some other java compiler?)
I agree. Here's the link:
subject: Beginner needs help!!
It's not a secret anymore!