I need Help with list in my Lab 3
Lab3:
1) Create data storage for each “user” with the attached “Person.java” file.
2) Implement the CompareTo() method from the “Comparable” interface inside the Person class.
3) Store all the users in an arrayList of “Person” objects.
4) Use an enhanced for loop to iterate through the arrayList of person objects and then compare the “temp” Person from the user input.
5) In this version, only return zero if the objects match (meaning password=password, username=username, and studentID=studentID)
This is my Person.java File
public class Person{private String username;private String password;private Long StudentID; public Person(String User, String Pass, Long ID){this.username = User;this.password = Pass;this.StudentID = ID;} public String getPassword (){return this.password;} public String getUsername(){return this.username;} public Long getStudentID(){return this.StudentID;}}
This is my LOGIN.java file
import javax.swing.JFrame;import java.awt.BorderLayout;public class Login{public static void main(String[] args){LoginGUI cuFrame = new LoginGUI();cuFrame.setVisible(true);cuFrame.setTitle(“Login”);cuFrame.setSize(300,150);cuFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }}
This is my LOGINGUI.java
import java.awt.event.*;
import java.awt.event.KeyAdapter;
import java.awt.event.ActionListener;import java.awt.BorderLayout;import java.awt.Dimension;import javax.swing.border.*;import javax.swing.*;
public class LoginGUI extends JFrame{private JTextField txtUser;private JTextField txtPass;private JTextField txtStuID;private JLabel lblUser;private JLabel lblPass;private JLabel lblStuID;private String keep = “”;private String finalPassword = “”;private JButton btnLogin;private JButton btnExit;private JPanel panel1; public LoginGUI(){setLayout(new BorderLayout(10,10));panel1 = new JPanel();panel1.setPreferredSize(new Dimension(250, 250)); txtUser = new JTextField();txtUser.setPreferredSize(new Dimension(150,20)); txtPass = new JTextField();txtPass.setPreferredSize(new Dimension(150,20)); txtPass.addKeyListener(new KeyAdapter() {public void keyTyped(KeyEvent arg0) {JTextField textField = (JTextField) arg0.getSource();keep += arg0.getKeyChar();String pressedKey = arg0.getKeyText(arg0.getKeyChar());String temp = “”;if (arg0.getKeyChar() == KeyEvent.VK_BACK_SPACE) {finalPassword = finalPassword.substring(0,finalPassword.length() – 1);for (int i = 0; i < finalPassword.length(); i++) {temp += “*”;}textField.setText(temp);} else if (“Enter”.equals(pressedKey)) {System.out.println(finalPassword);} else {finalPassword += (String.valueOf(arg0.getKeyChar())); arg0.setKeyChar(‘*’);}} });txtStuID = new JTextField();txtStuID.setPreferredSize(new Dimension(150,20));lblUser = new JLabel(“Username: “);lblPass = new JLabel(“Password: “);lblStuID = new JLabel(“StudentID: “); btnLogin = new JButton(“Login”);btnExit = new JButton(“Exit”); panel1.add(lblUser);panel1.add(txtUser);panel1.add(lblPass);panel1.add(txtPass);panel1.add(lblStuID);panel1.add(txtStuID);panel1.add(btnLogin);panel1.add(btnExit); ActionListener LoginAction = new LoginListener();btnLogin.addActionListener(LoginAction); ActionListener ExitAction = new ExitListener();btnExit.addActionListener(ExitAction);add(panel1, BorderLayout.CENTER);
} class ExitListener implements ActionListener{public void actionPerformed(ActionEvent event){System.exit(0);}} class LoginListener implements ActionListener{public void actionPerformed(ActionEvent event){Validate V = new Validate();//String pw = txtPass.getText() ;if (!keep.matches(“.*[A-Z].*[0-9].*”) && keep.length() < 10 ){JOptionPane.showMessageDialog(null,”Your Password needs atleast one Captial Letter or One Number n Your Password must contain atleast 10 Characters “);}else if (keep.contains(“,”) || keep.contains(” “)){JOptionPane.showMessageDialog(null,”Your Password must not have Comma or Space”);}else if (V.Verify(txtUser.getText(), keep, txtStuID.getText())){JOptionPane.showMessageDialog(null,”Your user account has been validated!”);}else{JOptionPane.showMessageDialog(null,”Your Username or Password is incorrect. Please try again”);} txtUser.setText(“”);txtPass.setText(“”);txtStuID.setText(“”);}} }
This is my Validate.java file
import java.util.*;import java.io.*;import javax.swing.JOptionPane;class Validate{public Boolean Verify(String u, String p, String i){try{Scanner FileScan = new Scanner(new File(“USERDATA2.txt”));while (FileScan.hasNextLine()){String S=FileScan.nextLine();String[] Sa= S.split(“,”);if( (u.equals(Sa[0])) && (p.equals(Sa[1])) && (i.equals(Sa[2])) ){FileScan.close();return true;}}FileScan.close();}catch(IOException e){JOptionPane.showMessageDialog(null, e.getMessage());}return false;}}
This is my USERDATE2.txt if you need it
USER1, fBqj!P4B33, 900000003USER2, 2Hmkq98NW+, 900000006USER3, _SNT8wsz85, 900000009USER4, 5LDz2H%t3t, 900000013USER5, at!tbX92FC, 900000016USER6, Kevin123456, 900
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
I Need Help With Explaining Why It Is Important For Leaders And Managers Of An O
/in Uncategorized /by developerI need help with explaining why it is important for leaders and managers of an organization or business to study public policy and understand its processes. I cant find 5 reliable sources within the past 5 years in order to write 6 sheets
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
I Need Help With Figure 7 9 7 8 And 7 4
/in Uncategorized /by developerI need help with figure 7-9, 7-8 and 7-4
Scenario SummaryUNION-G1 MGMNT-G1 UNION-G2 Changing Cells:% OFFSHORE 2004252525% OFFSHORE 2005255025% OFFSHORE 2006257525NOT PRODUCEDG1G1G22006 Result Cells:NET INCOME9501612…
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
I Need Help With Figuring Out How To Make The Needed Adjustments Adobe Photoshop
/in Uncategorized /by developerI need help with figuring out how to make the needed adjustments adobe photoshop assignment. My issue is after I crop the image, I create the rectangle bellow but it doesn’t actually show up and I cant see it once I click off of it except for in the layers panel on the right side.
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
I Need Help With Five Porter Forces On An Amazon S Case
/in Uncategorized /by developerI need help with Five porter forces on an Amazon’s case
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
I Need Help With Helping My Son Write A Essay
/in Uncategorized /by developerI need help with helping my son write a essay
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
I Need Help With His Assignment
/in Uncategorized /by developerI need help with his assignment
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
I Need Help With How To Make This In My Program Modify The Class Loan By Includi
/in Uncategorized /by developerI need help with how to make this in my program :
Loan monthly_payment Loanadd_loans,
float add_loans(Loan loan1, Loan loan2);
add_loans,paymentadd_loans monthly_paymentpayment
#include<iostream>
using namespace std;
class Loan {
public:
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
I Need Help With Ideas For A Project In The Project Management Class Project Sch
/in Uncategorized /by developerI need help with ideas for a project in the Project Management class Project Scheduling & Cost.
A project schedule is simply a tool which communicates which work should beperformed, the resources needed to perform the work as well as the timeframes within which thework ought to be…
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
I Need Help With Khan Academy
/in Uncategorized /by developerI need help with khan academy
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
I Need Help With List In My Lab 3 Lab3 Java File
/in Uncategorized /by developerI need Help with list in my Lab 3
Lab3:
1) Create data storage for each “user” with the attached “Person.java” file.
2) Implement the CompareTo() method from the “Comparable” interface inside the Person class.
3) Store all the users in an arrayList of “Person” objects.
4) Use an enhanced for loop to iterate through the arrayList of person objects and then compare the “temp” Person from the user input.
5) In this version, only return zero if the objects match (meaning password=password, username=username, and studentID=studentID)
This is my Person.java File
public class Person{private String username;private String password;private Long StudentID; public Person(String User, String Pass, Long ID){this.username = User;this.password = Pass;this.StudentID = ID;} public String getPassword (){return this.password;} public String getUsername(){return this.username;} public Long getStudentID(){return this.StudentID;}}
This is my LOGIN.java file
import javax.swing.JFrame;import java.awt.BorderLayout;public class Login{public static void main(String[] args){LoginGUI cuFrame = new LoginGUI();cuFrame.setVisible(true);cuFrame.setTitle(“Login”);cuFrame.setSize(300,150);cuFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }}
This is my LOGINGUI.java
import java.awt.event.*;
import java.awt.event.KeyAdapter;
import java.awt.event.ActionListener;import java.awt.BorderLayout;import java.awt.Dimension;import javax.swing.border.*;import javax.swing.*;
public class LoginGUI extends JFrame{private JTextField txtUser;private JTextField txtPass;private JTextField txtStuID;private JLabel lblUser;private JLabel lblPass;private JLabel lblStuID;private String keep = “”;private String finalPassword = “”;private JButton btnLogin;private JButton btnExit;private JPanel panel1; public LoginGUI(){setLayout(new BorderLayout(10,10));panel1 = new JPanel();panel1.setPreferredSize(new Dimension(250, 250)); txtUser = new JTextField();txtUser.setPreferredSize(new Dimension(150,20)); txtPass = new JTextField();txtPass.setPreferredSize(new Dimension(150,20)); txtPass.addKeyListener(new KeyAdapter() {public void keyTyped(KeyEvent arg0) {JTextField textField = (JTextField) arg0.getSource();keep += arg0.getKeyChar();String pressedKey = arg0.getKeyText(arg0.getKeyChar());String temp = “”;if (arg0.getKeyChar() == KeyEvent.VK_BACK_SPACE) {finalPassword = finalPassword.substring(0,finalPassword.length() – 1);for (int i = 0; i < finalPassword.length(); i++) {temp += “*”;}textField.setText(temp);} else if (“Enter”.equals(pressedKey)) {System.out.println(finalPassword);} else {finalPassword += (String.valueOf(arg0.getKeyChar())); arg0.setKeyChar(‘*’);}} });txtStuID = new JTextField();txtStuID.setPreferredSize(new Dimension(150,20));lblUser = new JLabel(“Username: “);lblPass = new JLabel(“Password: “);lblStuID = new JLabel(“StudentID: “); btnLogin = new JButton(“Login”);btnExit = new JButton(“Exit”); panel1.add(lblUser);panel1.add(txtUser);panel1.add(lblPass);panel1.add(txtPass);panel1.add(lblStuID);panel1.add(txtStuID);panel1.add(btnLogin);panel1.add(btnExit); ActionListener LoginAction = new LoginListener();btnLogin.addActionListener(LoginAction); ActionListener ExitAction = new ExitListener();btnExit.addActionListener(ExitAction);add(panel1, BorderLayout.CENTER);
} class ExitListener implements ActionListener{public void actionPerformed(ActionEvent event){System.exit(0);}} class LoginListener implements ActionListener{public void actionPerformed(ActionEvent event){Validate V = new Validate();//String pw = txtPass.getText() ;if (!keep.matches(“.*[A-Z].*[0-9].*”) && keep.length() < 10 ){JOptionPane.showMessageDialog(null,”Your Password needs atleast one Captial Letter or One Number n Your Password must contain atleast 10 Characters “);}else if (keep.contains(“,”) || keep.contains(” “)){JOptionPane.showMessageDialog(null,”Your Password must not have Comma or Space”);}else if (V.Verify(txtUser.getText(), keep, txtStuID.getText())){JOptionPane.showMessageDialog(null,”Your user account has been validated!”);}else{JOptionPane.showMessageDialog(null,”Your Username or Password is incorrect. Please try again”);} txtUser.setText(“”);txtPass.setText(“”);txtStuID.setText(“”);}} }
This is my Validate.java file
import java.util.*;import java.io.*;import javax.swing.JOptionPane;class Validate{public Boolean Verify(String u, String p, String i){try{Scanner FileScan = new Scanner(new File(“USERDATA2.txt”));while (FileScan.hasNextLine()){String S=FileScan.nextLine();String[] Sa= S.split(“,”);if( (u.equals(Sa[0])) && (p.equals(Sa[1])) && (i.equals(Sa[2])) ){FileScan.close();return true;}}FileScan.close();}catch(IOException e){JOptionPane.showMessageDialog(null, e.getMessage());}return false;}}
This is my USERDATE2.txt if you need it
USER1, fBqj!P4B33, 900000003USER2, 2Hmkq98NW+, 900000006USER3, _SNT8wsz85, 900000009USER4, 5LDz2H%t3t, 900000013USER5, at!tbX92FC, 900000016USER6, Kevin123456, 900
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"