• Post Reply Bookmark Topic Watch Topic
  • New Topic

Beginner needs help!!

 
Josh Wetzel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
Josh
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what does you compile command look like? (for example, are you using any special switches? Are you using javac or some other java compiler?)
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!