Sunday 15 April 2012

java - How do I pass in user inputed variables into a constructor? -


I need some help with this program. User ID, password, number of maximum attempts and amp; The maximum number of uses and they have to go to a constructor ... can someone pass me in the constructor? I'm using Java Thanks!

Import java.util.Scanner; Public class LoginPw {public static zero main (string [] args) // // TODO auto generated method stub scanner reader = new scanner (System.in); System.out.println ("Enter in your ID and password"); Int idnum = reader.nextInt (); Int password = reader.nextInt (); System.out.println ("Enter the maximum number of attempts"); Int maxtries = reader.nextInt (); System.out.println ("Enter Maximum Number of Uses"); Int maxuses = reader.nextInt (); PwLogin pwl = new PwLogin (idnum, password, maxtries, maxuses); }} Class PwLogin {public PwLogin (int id, int pw) {// maximum number tries to denote the value of 0 This (ID, PW, 0,0); // Call 4-Logic Maker w / MaxTries & amp; The maximum use denominated in the form of zero (infinite) public PwLogin (tries int id, int pw, int) {/ assuming that the maximum number of uses is infinite, denote the value of 0. This (ID, PW, Effort, 0); // Call the 4-Logic Constructor with the maximum defaults in the form of zero (infinite) public PwLogin (uses int id, int pw, int tries, int) {// Now 4 classes with pass-in arguments Set the variable. = ID; This.password = pw; This.maxtries = tries; Uses this.maxuses =; }}

You need to declare member variable in Java:

  class PwLogin {Private Int idnum; Personalized passwords; Private Industries Maxriss; Private Int Max; Public PwLogin (int id, int pw) {etc ...  

No comments:

Post a Comment