• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Beginner needs help!!

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?)
 
I found some pretty shells, some sea glass and this lovely tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic