static void postTeamConstraints(IntSetVar E, int n, int[] nbMembers, IntSetVarArray memberSets)
     throws Failure {
   C.postConstraint(E.cardinality().eq(n));
   for (int i = 0; i < nbMembers.length; i++) {
     C.postConstraint(E.intersectionWith(memberSets.get(i)).cardinality().ge(nbMembers[i]));
   }
 }
    static void test() {
      IntSetVarArray memberSets = new IntSetVarArray(C, 5);

      memberSets.set(Stewards, 0);
      memberSets.set(Hostesses, 1);
      memberSets.set(French, 2);
      memberSets.set(German, 3);
      memberSets.set(Spanish, 4);

      try {
        for (int i = 0; i < crews.size() - 1; i++) {
          crews.get(i).nullIntersectWith(crews.get(i + 1)).execute();
          if ((i + 2) < 10) {
            crews.get(i).nullIntersectWith(crews.get(i + 2)).execute();
          }
        }

        for (int i = 0; i < crews.size(); i++) {
          postTeamConstraints(
              crews.get(i),
              req[i][iNbMembers],
              new int[] {
                req[i][iStewards],
                req[i][iHostesses],
                req[i][iFrench],
                req[i][iGerman],
                req[i][iSpanish]
              },
              memberSets);
        }

        assertTrue(
            "Solution for crews task wasn't found", C.execute(new GoalIntSetGenerate(crews)));
        checkResults(crews);

      } catch (Failure f) {
        fail("test failed due to Failure exception's being thrown");
      }
    }
    static void checkResults(IntSetVarArray array) {
      int size = array.size();
      for (int i = 0; i < size; i++) {
        IntSetVar var = array.get(i);
        Set checkSet = var.requiredSet();
        assertTrue(checkSet.size() >= req[i][iNbMembers]);
        assertTrue(intersectionCardinality(checkSet, Stewards.possibleSet()) >= req[i][iStewards]);
        assertTrue(
            intersectionCardinality(checkSet, Hostesses.possibleSet()) >= req[i][iHostesses]);
        assertTrue(intersectionCardinality(checkSet, French.possibleSet()) >= req[i][iFrench]);
        assertTrue(intersectionCardinality(checkSet, German.possibleSet()) >= req[i][iGerman]);
        assertTrue(intersectionCardinality(checkSet, Spanish.possibleSet()) >= req[i][iSpanish]);
      }
      for (int i = 0; i < size - 2; i++) {
        assertTrue(
            intersectionCardinality(array.get(i).requiredSet(), array.get(i + 1).requiredSet())
                == 0);
      }

      assertTrue(
          intersectionCardinality(
                  array.get(size - 2).requiredSet(), array.get(size - 1).requiredSet())
              == 0);
    }
 static void printSetArray(IntSetVarArray array, boolean requiredOnly) {
   for (int i = 0; i < array.size(); i++) {
     printSet(array.get(i), requiredOnly);
     System.out.println("");
   }
 }