READ THIS: DO NOT GIVE ME A CODE THAT ISNT PART OF MY CODE. DO NOT GIVE A CODE THAT IS COPIED FROM SOMEONE ELSE CHEGG. JUST HELP ME WITH MY OWN CODE. edit and finish class authenticate below do not give a solution (example copying from another source and giving it as a solution) that is not part of my code below. Also provided is user class. HELP ME FINISH CLASS AUTHENTICATE. I have done some but am stuck. I also provided the user class. The task is also there incase you are confused what Im trying to complete //Authenticate.java //FINISH THIS! import java.util.Scanner; import java.io.File; Class Authenticate { private final int SIZE = 100; private User() users = new User[SIZE]; public Authenticator (String fileName) throws Exception; Scanner sc = new Scanner(new File(fileName)); int i = 0; While(sc.hasNext() && i < SIZE) { users[i] = Users.read(sc); i++ } } public void authenticate(String username, String password) throws Exception{ try { User u = null; for(User X : users) { if(x.getUsername().equals(username) && x.verifyPassword(password){ return ; //FINISH THIS DO NOT GIVE ANOTHER SOLUTION THAT ISNT NOT CONTINUING THIS CODE //READ THIS: DO NOT GIVE ME A CODE THAT ISNT PART OF MY CODE. DO NOT GIVE A CODE THAT IS COPIED FROM SOMEONE ELSE. JUST HELP ME WITH MY OWN CODE. _________________________________________________________________ //User.java import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class User { private String username; private String password; private String hint; public User(String username, String password, String hint) { this.username = username; this.password = password; this.hint = hint; } public boolean verifyPassword(String Password) { return Password.equals(password); } public String toString() { return "User "+username; } public static User read(Scanner scanner) { if(scanner.hasNext()){ }else {return null;} return new User(scanner.next(), scanner.next(), scanner.next()); } public String getUsername() { return username; } public String getHint() { return hint; } } DO NOT COPY A SOLUTION FROM CHEGG, HELP ME ON MY CLASS AUTHENICATE. THIS IS THE 4TH TIME GETTING A SOLUTION THAT IS NOT PART OF MINE. ABOVE IS WHAT I HAVE DONE SO FAR. READ THIS: DO NOT GIVE ME A CODE THAT ISNT PART OF MY CODE. DO NOT GIVE A CODE THAT IS COPIED FROM SOMEONE ELSE. JUST HELP ME WITH MY OWN CODE ABOVE. For example, if the file users.data contains: weiss puppy2 woof-woof arnow java cuppa sokol brooklyn college READ THIS: DO NOT GIVE ME A CODE THAT ISNT PART OF MY CODE. DO NOT GIVE A CODE THAT IS COPIED FROM SOMEONE ELSE. JUST HELP ME WITH MY OWN CODE ABOVE. here are some sample excutions of the program: username? arnow password? java Welcome to the system Sample Test Run #2 Given the same users.data file as above, execution of the program should look like: username? weiss password? dontremember *** Invalid password - hint: woof-woof username? weiss password? puppy2 Welcome to the system Sample Test Run #3 Given the same users.data file as above, execution of the program should look like: username? sokol password? CUNY *** Invalid password - hint: college username? sokol password? SUNY *** Invalid password - hint: college username? sokol password? BC *** Invalid password - hint: college Too many failed attempts... please try again later //READ THIS: DO NOT GIVE ME A CODE THAT ISNT PART OF MY CODE. DO NOT GIVE A CODE THAT IS COPIED FROM SOMEONE ELSE. JUST HELP ME WITH MY OWN CODE.
READ THIS: DO NOT GIVE ME A CODE THAT ISNT PART OF MY CODE. DO NOT GIVE A CODE THAT IS COPIED FROM SOMEONE ELSE CHEGG. JUST HELP ME WITH MY OWN CODE.
edit and finish class authenticate below do not give a solution (example copying from another source and giving it as a solution) that is not part of my code below. Also provided is user class.
HELP ME FINISH CLASS AUTHENTICATE. I have done some but am stuck. I also provided the user class. The task is also there incase you are confused what Im trying to complete
//Authenticate.java
//FINISH THIS!
import java.util.Scanner;
import java.io.File;
Class Authenticate {
private final int SIZE = 100;
private User() users = new User[SIZE];
public Authenticator (String fileName) throws Exception;
Scanner sc = new Scanner(new File(fileName));
int i = 0;
While(sc.hasNext() && i < SIZE) {
users[i] = Users.read(sc);
i++
}
}
public void authenticate(String username, String password) throws Exception{
try {
User u = null;
for(User X : users) {
if(x.getUsername().equals(username) && x.verifyPassword(password){
return ;
//FINISH THIS DO NOT GIVE ANOTHER SOLUTION THAT ISNT NOT CONTINUING THIS CODE
//READ THIS: DO NOT GIVE ME A CODE THAT ISNT PART OF MY CODE. DO NOT GIVE A CODE THAT IS COPIED FROM SOMEONE ELSE. JUST HELP ME WITH MY OWN CODE.
_________________________________________________________________
//User.java
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class User
{
private String username;
private String password;
private String hint;
public User(String username, String password, String hint)
{
this.username = username;
this.password = password;
this.hint = hint;
}
public boolean verifyPassword(String Password)
{
return Password.equals(password);
}
public String toString()
{
return "User "+username;
}
public static User read(Scanner scanner)
{
if(scanner.hasNext()){ }else {return null;}
return new User(scanner.next(), scanner.next(), scanner.next());
}
public String getUsername()
{
return username;
}
public String getHint()
{
return hint;
}
}
DO NOT COPY A SOLUTION FROM CHEGG, HELP ME ON MY CLASS AUTHENICATE. THIS IS THE 4TH TIME GETTING A SOLUTION THAT IS NOT PART OF MINE. ABOVE IS WHAT I HAVE DONE SO FAR.
READ THIS: DO NOT GIVE ME A CODE THAT ISNT PART OF MY CODE. DO NOT GIVE A CODE THAT IS COPIED FROM SOMEONE ELSE. JUST HELP ME WITH MY OWN CODE ABOVE.
For example, if the file users.data contains:
weiss puppy2 woof-woof
arnow java cuppa
sokol brooklyn college
READ THIS: DO NOT GIVE ME A CODE THAT ISNT PART OF MY CODE. DO NOT GIVE A CODE THAT IS COPIED FROM SOMEONE ELSE. JUST HELP ME WITH MY OWN CODE ABOVE.
here are some sample excutions of the program:
username? arnow
password? java
Welcome to the system
Sample Test Run #2
Given the same users.data file as above, execution of the program should look like:
username? weiss
password? dontremember
*** Invalid password - hint: woof-woof
username? weiss
password? puppy2
Welcome to the system
Sample Test Run #3
Given the same users.data file as above, execution of the program should look like:
username? sokol
password? CUNY
*** Invalid password - hint: college
username? sokol
password? SUNY
*** Invalid password - hint: college
username? sokol
password? BC
*** Invalid password - hint: college
Too many failed attempts... please try again later
//READ THIS: DO NOT GIVE ME A CODE THAT ISNT PART OF MY CODE. DO NOT GIVE A CODE THAT IS COPIED FROM SOMEONE ELSE. JUST HELP ME WITH MY OWN CODE.
Step by step
Solved in 6 steps with 3 images