Advertisement
Kuroshi1

listContains revamped

Jan 22nd, 2022
1,202
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public boolean killRingContains(String name) {
  2.         AssassinNode current = ringFront;
  3.         return listContains(current, name);
  4.     }
  5.  
  6.     public boolean graveyardContains(String name) {
  7.         AssassinNode current = graveyardFront;
  8.         return listContains(current, name);
  9.     }
  10.  
  11.     public boolean gameOver() {
  12.         return ringFront.next == null;
  13.     }
  14.  
  15.     public String winner() {
  16.         if (!gameOver()) {
  17.             return null;
  18.         }
  19.         return ringFront.name;
  20.     }
  21.  
  22.     private boolean listContains(AssassinNode current, String name) {
  23.         while (current != null) {
  24.             if (current.name.toLowerCase() == name.toLowerCase()) {
  25.                 return true;
  26.             }
  27.             current = current.next;
  28.         }
  29.         return false;
  30.     }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement