I have two objects, player1 and player 2. These two objects have properties: String first name,String last name, double weight and int grade. I want to create a method that takes in a player object and compares it with the players in my list. So, for example, something like this:
protected void find(T target) // Searches list for an occurence of an element e such that // e.equals(target). If successful, sets instance variables // found to true and location to the array index of e. If // not successful, sets found to false. { location = 0; found = false; while (location < numElements) { if ([B]list[location].equals(target)[/B]) { found = true; return; } else location++; } }
But when I pass in a player with the EXACT same attributes as a player in the list, the equals method still returns false. What do I have to do to compare two players so that
returns true?player1 = (George, Lemons, 180, 9) player2 = (George, Lemons, 180, 9) player1.equals(player2)