Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void removeGame(String name) throws IllegalArgumentException {
- if(name == null) {
- throw new IllegalArgumentException();
- }
- Game current = head;
- Game previous = null;
- Game next = current.getNext();
- while(current.getNext() != null) {
- next = current.getNext();
- if(current.getName() == name) {
- if (previous != null) {
- previous.setNext(next);
- } else {
- head = next;
- }
- previous = current;
- current = next;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement