(Trash t)
| 15 | this.binType = binType; |
| 16 | } |
| 17 | @SuppressWarnings("unchecked") |
| 18 | boolean grab(Trash t) { |
| 19 | // Compare class types: |
| 20 | if(t.getClass().equals(binType)) { |
| 21 | add((T)t); // Downcast to this TrashBin type |
| 22 | return true; // Trash grabbed |
| 23 | } |
| 24 | return false; // Trash not grabbed |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | class TrashBinList<T extends Trash> |