Can someone help me out on my add method. It has to add an element to the list (goals, assists, ppg, etc). I got the sort, remove, and count to work but no this. This is my project which is due today.
I am using the removeOrAdd method, and in that method, the remove part works but not the add part. I tried doing new DataBase().processing(); but that does not add new elements to the previous elements.
Like for example.
(Andrew is not there anymore), but a new element(or s) is there.
Can you guys please help me out? This assignment is due in 2 hours. Sorry for rushing you guys. I worked hard on this code, and got everything to work except the adding elements part.
Well, obviously the add part doesn't work. It's an empty block:
What have you tried to put in there?Code:
I left it blank because I don't understand what to put in there. I tried to put new DataBase().processing(); to call the whole processing method again, but it creates a new list instead of adding it to the previous list.
Okay. Well, you need to create a new Pair object to put in the list. To do that, you'll need to get all the variables that make up a Pair object.
Looking at your definition of the Pair class, I really have no idea why you're passing an Object and a Comparable to its constructor. But the other arguments sound like things you should be getting from the user. So use the same techniques you've been using to ask the user for goals, assists, and gamesPlayed. Then use those values to create a new Pair object, and call List.add() to add it to the list.
List (Java Platform SE 6))