Advertisement
Guest User

Untitled

a guest
Apr 17th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public void removeGame(String name) throws IllegalArgumentException {
  2.  
  3. if(name == null) {
  4. throw new IllegalArgumentException();
  5. }
  6.  
  7. Game current = head;
  8. Game previous = null;
  9. Game next = current.getNext();
  10.  
  11. while(current.getNext() != null) {
  12. next = current.getNext();
  13. if(current.getName() == name) {
  14. if (previous != null) {
  15. previous.setNext(next);
  16. } else {
  17. head = next;
  18. }
  19. previous = current;
  20. current = next;
  21.  
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement