public void invite(Follower follower, String type) { if (list.containsKey(type)) { return; } if (follower.accept(this, type)) { list.put(type, follower); } }
public void startWork() { while (!leader.isDone() && avaiableList.size() > 0) { for (String type : DanceTask.typeList) { List<Follower> unavaiableList = new ArrayList<>(); for (Follower follower : avaiableList) { if (follower.isDone() || follower.cannotAcceptFollower(leader)) { unavaiableList.add(follower); continue; } leader.invite(follower, type); } avaiableList.removeAll(unavaiableList); } } this.isDone = true; }