Hi! I just need some help with this program. The user has to enter in the id,password,the number of max tries & the number of max uses. And they have to go into a constructor... Could someone help me pass them into the constructor? I'm using java. Thanks!
import java.util.Scanner;
public class LoginPw{
public static void 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 in the max number of tries");
int maxtries = reader.nextInt();
System.out.println("Enter in the number of max uses");
int maxuses = reader.nextInt();
PwLogin pwl = new PwLogin(idnum,password,maxtries,maxuses);
}}
class PwLogin{
public PwLogin(int id, int pw){
//assumes max num of tries is infinite. denote by value of 0.
this(id,pw,0,0); //call the 4-argument constructor w/ maxTries & maxUses defaulted as zero(infinite)
}
public PwLogin(int id, int pw, int tries){
//assumes max number of uses is infinite. denote by value of 0.
this(id, pw, tries,0); //Call the 4-argument constructor with maxUses defaulted as zero (infinite)
}
public PwLogin(int id, int pw, int tries, int uses){
// Now set the 4 class variables from the passed-in arguments
this.idnum =id;
this.password = pw;
this.maxtries=tries;
this.maxuses=uses;
}
}