Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to be able to search a Linked List for certain unique elements (username,

ID: 3640455 • Letter: I

Question

I need to be able to search a Linked List for certain unique elements (username, password, email) and after finding these elements I need to go to the next node in the list and begin a series of statements allowing users to change profile information but I have no idea how to accomplish this. I have tried several things but they all fail.

**How GUI Looks** http://img.photobucket.com/albums/v82/gspeach79/profile.jpg

**Link to Account Class:** http://pastebin.com/jnBrcnP1

So the User fills out the Required information and if they want to change profile information such as "Name" or "Gender" they change the information then set the ComboBox next to it to "Yes" then click the button "Save Settings".

**Here is what the Linked List looks like:**

tobi
tobi123
tobi@hotmail.com
tobi
Mixed Breed
Male
1-2
Virginia
Walking
peppy
peppy123
peppy@hotmail.com
peppy
Chihuahua
Male
5-6
Virginia
Eating

**Here is my code so far:**

private void jButtonP1ActionPerformed(java.awt.event.ActionEvent evt) {
//New Linked List created from file
LinkedList<Account> account = new LinkedList<Account>();
//user information
String username = jTextFieldP3.getText();
String password = jPasswordFieldP1.getText();
String email = jTextFieldP4.getText();
String name = jTextFieldP1.getText();
String breed = (String) jComboBoxP4.getSelectedItem();
String gender = (String) jComboBoxP3.getSelectedItem();
String age = (String) jComboBoxP1.getSelectedItem();
String state = (String) jComboBoxP2.getSelectedItem();
String hobby = jTextFieldP2.getText();
//change combo boxes
String userchange = (String) jComboBoxP12.getSelectedItem();
String passchange = (String) jComboBoxP13.getSelectedItem();
String emailchange = (String) jComboBoxP14.getSelectedItem();
String namechange = (String) jComboBoxP6.getSelectedItem();
String breedchange = (String) jComboBoxP7.getSelectedItem();
String genderchange = (String) jComboBoxP8.getSelectedItem();
String agechange = (String) jComboBoxP9.getSelectedItem();
String statechange = (String) jComboBoxP10.getSelectedItem();
String hobbychange = (String) jComboBoxP11.getSelectedItem();

//cancel combo box
String accountcancel = (String) jComboBoxP5.getSelectedItem();

//Creates Linked List from File

if(username.equals("") || password.equals("") || email.equals("")) // If password and username is empty > Do this >>>
{
jButtonP1.setEnabled(false);
jTextFieldP3.setText("");
jPasswordFieldP1.setText("");
jTextFieldP4.setText("");
jButtonP1.setEnabled(true);
this.setVisible(true);
}
else
{
Object search = username;

for(
ListIterator<Account> itr = account.listIterator();
itr.hasNext();
itr.next( )
){
Account item = itr.next();

if(item.equals(search))
{
System.out.println(item);
}


}

}

}

Explanation / Answer

DONT FORGET TO RATE LIFESAVER!!!

call thisfunction inside your ActionListener. If you want further information from Account just change boolean to Account.

boolean isUserAvailable(String username, String password, String email) {

boolean found = false;

ListIterator<Account> itr = account.listIterator();

while (itr.hasNext()) {

Account item = itr.next();

if(item.getUsername().equals(username) &&

item.getPassword().equals(password) &&

item.getEmail().equals(username)) {

found =true;

}

}

return found;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote