Пример #1
0
 public void setWizardSpellbook(Data wizardSpellbook) {
   wizardSpellbook.abilName = "Spellbook";
   wizardSpellbook.dlevel = 1;
   wizardSpellbook.dClass = "Wizard";
   wizardSpellbook.flavor =
       "At 1st level, you have a spellbook containing six 1st-level wizard spells of your choice.";
 }
 public Reserva(
     String id,
     float preu,
     boolean penalitzacioTemps,
     boolean penalitzacioMoto,
     float penalitzacio,
     String dataInicial,
     String horaInicial,
     String dataFinal,
     String horaFinal,
     Local localInicial,
     Local localFinal,
     Client clientReserva,
     String idMoto) {
   this.id = id;
   this.preu = preu;
   this.penalitzacioTemps = penalitzacioTemps;
   this.penalitzacioMoto = penalitzacioMoto;
   this.penalitzacio = penalitzacio;
   this.dataInicial = Data.crearData(dataInicial, horaInicial);
   this.dataFinal = Data.crearData(dataFinal, horaFinal);
   this.localInicial = localInicial;
   this.localFinal = localFinal;
   this.clientReserva = clientReserva;
   if (localFinal.getMoto(idMoto) != null) {
     this.motoReserva = localFinal.getMoto(idMoto);
   } else {
     this.motoReserva = localInicial.getMoto(idMoto);
   }
 }
Пример #3
0
  public String execute() {
    StringParseDouble ps = new StringParseDouble();
    Double na[] = ps.parse(this.na);
    Double nh[] = ps.parse(this.nh);
    Double w[] = ps.parse(this.w);
    Double ag[] = ps.parse(this.ag);
    Double oh[] = ps.parse(this.oh);
    Student stu = (Student) ActionContext.getContext().getSession().get("student");
    org.jevy.model.Teams team = (new GetTeamByStudent()).getTeams(enid, stu);
    Data data = new Data();
    DataDAO dataDAO = new DataDAO();
    for (int i = 0; i < na.length; i++)
      if (na[i].doubleValue() != 0.0D && cag != 0.0D && coh != 0.0D) {
        data.setData1(na[i]);
        data.setData2(nh[i]);
        data.setData3(w[i]);
        data.setData4(ag[i]);
        data.setData5(oh[i]);
        data.setData6(Double.valueOf(cag));
        data.setData7(Double.valueOf(coh));
        data.setLabel((new StringBuilder("salt")).append(i).toString());
        data.setTeams(team);
        dataDAO.save(data);
      }

    return "success";
  }
Пример #4
0
    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {
      // TODO Auto-generated method stub

      ViewHolder holder = null;
      if (convertView == null) {
        holder = new ViewHolder();
        convertView = inflater.inflate(R.layout.simple_list_item_msginfo, null);
        // 注意这里是convertview
        holder.itemName = (TextView) convertView.findViewById(R.id.item_msginfo_name);
        holder.itemDate = (TextView) convertView.findViewById(R.id.item_msginfo_date);
        holder.itemTime = (TextView) convertView.findViewById(R.id.item_msginfo_time);
        holder.itemLocation = (TextView) convertView.findViewById(R.id.item_msginfo_location);
        holder.itemSponsor = (TextView) convertView.findViewById(R.id.item_msginfo_sponsor);
        convertView.setTag(holder);
        Log.d("MsgInfoActivity", "convertView == null");
      } else {
        holder = (ViewHolder) convertView.getTag();
      }

      holder.itemName.setText((String) Data.get(position).get("ACTIVITY_NAME"));
      holder.itemDate.setText((String) Data.get(position).get("ACTIVITY_DATE"));
      holder.itemTime.setText((String) Data.get(position).get("ACTIVITY_TIME"));
      holder.itemLocation.setText((String) Data.get(position).get("ACTIVITY_LOCATION"));
      holder.itemSponsor.setText((String) Data.get(position).get("ACTIVITY_SPONSOR"));
      return convertView;
    }
Пример #5
0
  @Test
  public void testBasicFieldStats() {
    Field f = Data.makeColumnField("a", "label", new Object[] {"1", "2", "a", "2", null, 0});
    Field g = Data.makeColumnField("a", "label", new Object[] {100, 200, 400, 500, 600});
    Field h = Data.makeColumnField("a", "label", new Object[] {"a", "b", "c", "c"});
    Field i = Data.makeIndexingField("a", "label", 20);
    Field c = Data.makeConstantField("a", "label", 5.0, 2000);

    assertEquals(0, f.min(), 0.01);
    assertEquals(2, f.max(), 0.01);

    assertEquals(100, g.min(), 0.01);
    assertEquals(600, g.max(), 0.01);

    assertEquals(null, h.min());
    assertEquals(null, h.max());

    assertEquals(1, i.min(), 0.01);
    assertEquals(20, i.max(), 0.01);

    assertEquals(5.0, c.min(), 0.01);
    assertEquals(5.0, c.max(), 0.01);

    int[] counts = (int[]) h.property("categoryCounts");
    Assert.assertEquals(1, counts[0]);
    Assert.assertEquals(1, counts[1]);
    Assert.assertEquals(2, counts[2]);

    assertEquals(4, f.uniqueValuesCount());
    assertEquals(5, g.uniqueValuesCount());
    assertEquals(3, h.uniqueValuesCount());
    assertEquals(20, i.uniqueValuesCount());
    assertEquals(1, c.uniqueValuesCount());
  }
Пример #6
0
 /** Test of renderChildren method, of class Activity. */
 @Test
 public void testCreateChildren() throws Exception {
   System.out.println("renderChildren");
   // Setup
   ChildPane childPane = new ChildPane();
   childPane.setChild("Child");
   VBox vbox = VBoxBuilder.create().children(childPane).build();
   Parent parent = new Parent();
   parent.setScene(vbox);
   Data data = new Data();
   Map<Field, Object> fieldParams = new HashMap<Field, Object>();
   for (Field field : data.getClass().getDeclaredFields()) {
     field.setAccessible(true);
     fieldParams.put(field, field.get(data));
   }
   RenderParameter renderParam = new RenderParameter();
   String id = renderParam.putParam("checkForLabel", "CheckForLabel");
   childPane.setId(id);
   parent.createChildren(fieldParams, renderParam, ValidationResult.getEmptyResult());
   // Assertoin
   Child child = (Child) parent.getChildActivities(Child.class).get(0);
   assertNotNull(child);
   assertNotNull(child.getScene());
   assertEquals(childPane, child.getScene());
   assertEquals(parent, child.getParent());
   VBox cvbox = (VBox) child.getScene().getChildren().get(0);
   assertTrue(cvbox.getChildren().get(0) instanceof Button);
   assertTrue(cvbox.getChildren().get(1) instanceof Label);
   assertEquals(data.checkForButton, ((Button) cvbox.getChildren().get(0)).getText());
   assertEquals("CheckForLabel", ((Label) cvbox.getChildren().get(1)).getText());
 }
 public void writeExternal(final Element element) throws WriteExternalException {
   super.writeExternal(element);
   JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element);
   writeModule(element);
   DefaultJDOMExternalizer.writeExternal(this, element);
   final Data persistentData = getPersistentData();
   DefaultJDOMExternalizer.writeExternal(persistentData, element);
   EnvironmentVariablesComponent.writeExternal(element, persistentData.getEnvs());
   final String dirName = persistentData.getDirName();
   if (!dirName.isEmpty()) {
     final Element dirNameElement = new Element("dir");
     dirNameElement.setAttribute("value", FileUtil.toSystemIndependentName(dirName));
     element.addContent(dirNameElement);
   }
   final Element patternsElement = new Element(PATTERNS_EL_NAME);
   for (String o : persistentData.getPatterns()) {
     final Element patternElement = new Element(PATTERN_EL_NAME);
     patternElement.setAttribute(TEST_CLASS_ATT_NAME, o);
     patternsElement.addContent(patternElement);
   }
   final String forkMode = getForkMode();
   if (!forkMode.equals("none")) {
     final Element forkModeElement = new Element("fork_mode");
     forkModeElement.setAttribute("value", forkMode);
     element.addContent(forkModeElement);
   }
   element.addContent(patternsElement);
   PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
 }
Пример #8
0
 @Override
 public boolean equals(Object obj) {
   if (obj == null || getClass() != obj.getClass()) return false;
   if (obj == this) return true;
   Data d = (Data) obj;
   return (this.dia == d.getDia() && this.mes == d.getMes() && this.ano == d.getAno());
 }
 public void bePatternConfiguration(List<PsiClass> classes, PsiMethod method) {
   myData.TEST_OBJECT = TEST_PATTERN;
   final Set<String> patterns = new HashSet<String>();
   final String methodSufiix;
   if (method != null) {
     myData.METHOD_NAME = method.getName();
     methodSufiix = "," + myData.METHOD_NAME;
   } else {
     methodSufiix = "";
   }
   for (PsiClass pattern : classes) {
     patterns.add(JavaExecutionUtil.getRuntimeQualifiedName(pattern) + methodSufiix);
   }
   myData.setPatterns(patterns);
   final Module module =
       PatternConfigurationProducer.findModule(
           this, getConfigurationModule().getModule(), patterns);
   if (module == null) {
     myData.setScope(TestSearchScope.WHOLE_PROJECT);
     setModule(null);
   } else {
     setModule(module);
   }
   setGeneratedName();
 }
Пример #10
0
 @SuppressWarnings("unchecked")
 public void addData(int value, String name) {
   Data data = new Data();
   data.value = value;
   data.name = name;
   this.data.add(data);
 }
Пример #11
0
  public void createUser(
      String login, String password, int backupNbr, Captcha captcha, String answer)
      throws Exception {
    LOG.info("creating user: "******", " + password + ", " + backupNbr + ", answer=" + answer);
    LOG.info("captcha=" + captcha);
    OCPUser user = new OCPUser(this, login, backupNbr);
    UserPublicInfo upi = user.getPublicInfo(this);

    ContactMap contactMap = ds().getComponent(ContactMap.class);
    Contact contact = contactMap.getContact(captcha.contactId);

    // 1) create the public part of the user.
    // catpcha is required in order to avoid massive fake user creation
    Data publicUserData = new Data(this, user, ds().serializer.serialize(upi));
    Link publicUserDataLink =
        new Link(user, this, UserPublicInfo.getKey(this, login), publicUserData.getKey(this));

    getClient().createUser(contact, publicUserData, publicUserDataLink, captcha, answer);

    // 2) create the private part of the user.
    // no need captcha because creation of object is checked by the user
    // public info
    Key key = new Key(hash(ucrypt(password, (login + password).getBytes())));
    byte[] content = ucrypt(password, ds().serializer.serialize(user));
    Content privateUserData = new Data(this, user, content);
    Link privateUserDataLink = new Link(user, this, key, privateUserData.getKey(this));

    setWithLink(user, privateUserData, privateUserDataLink);
  }
 /** @deprecated using deprecated api */
 protected void store() {
   Data data = new Data();
   data.i_map = db().collections().newHashMap(10);
   setDefaultValues(data.i_map);
   data.i_helper = helper(10);
   store(data);
 }
 private void restoreMembers(Data data) {
   Query q = newQuery(Data.class);
   ObjectSet objectSet = q.execute();
   Data rdata = (Data) objectSet.next();
   data.i_map = rdata.i_map;
   data.i_helper = rdata.i_helper;
 }
Пример #14
0
 public void setWizardRitualCasting(Data wizardRitualCasting) {
   wizardRitualCasting.abilName = "Ritual Casting";
   wizardRitualCasting.dlevel = 1;
   wizardRitualCasting.dClass = "Wizard";
   wizardRitualCasting.flavor =
       "You can cast a wizard spell as a ritual if that spell has the ritual tag and you have the spell in your spellbook. You don't need to have the spell prepared.\n";
 }
Пример #15
0
 public void train(Data<Type> signal, Data<Type> background) {
   nSignal = signal.getEvents().size();
   nBackground = background.getEvents().size();
   int numTries = 10000;
   double minError = 1000;
   double[] bestWeights = new double[8];
   double[] potentialWeights = new double[8];
   for (int a = 0; a < numTries; a++) {
     for (int i = 0; i < 8; i++) {
       potentialWeights[i] = Math.random() * 2 - 1;
     }
     double errorPotential = 0;
     for (Type event : signal.getEvents()) {
       double result = sigmoidFunction(potentialWeights, event);
       errorPotential += 1 - result;
     }
     for (Type event : background.getEvents()) {
       double result = sigmoidFunction(potentialWeights, event);
       errorPotential += result;
     }
     errorPotential = errorPotential / (nSignal + nBackground);
     if (errorPotential < minError) {
       bestWeights = potentialWeights;
       minError = errorPotential;
       System.out.println("Hi");
       System.out.println(minError);
     }
   }
   weights = bestWeights;
   for (int i = 0; i < 8; i++) {
     System.out.println(bestWeights[i]);
   }
 }
Пример #16
0
  @Override
  public void buildModel() {

    rows = new IntVar[n][n];
    cols = new IntVar[n][n];
    carres = new IntVar[n][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (data.grid(i, j) > 0) {
          rows[i][j] = VariableFactory.fixed(data.grid(i, j), solver);
        } else {
          rows[i][j] = VariableFactory.enumerated("c_" + i + "_" + j, 1, n, solver);
        }
        cols[j][i] = rows[i][j];
      }
    }

    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          carres[j + k * 3][i] = rows[k * 3][i + j * 3];
          carres[j + k * 3][i + 3] = rows[1 + k * 3][i + j * 3];
          carres[j + k * 3][i + 6] = rows[2 + k * 3][i + j * 3];
        }
      }
    }

    for (int i = 0; i < n; i++) {
      solver.post(IntConstraintFactory.alldifferent(rows[i], "AC"));
      solver.post(IntConstraintFactory.alldifferent(cols[i], "AC"));
      solver.post(IntConstraintFactory.alldifferent(carres[i], "AC"));
    }
  }
Пример #17
0
 public boolean parse(
     int level, Source source, boolean parentNot, boolean caseSensitive, boolean receive) {
   data.pushDefaultSyntaxError();
   boolean match = element.parse(level, source, parentNot, caseSensitive, receive);
   data.popDefaultSyntaxError();
   return match;
 }
  public MethodPropertyContext(Method getter) {
    synchronized (cache) {
      Data previous = cache.get(getter);
      if (previous != null) {
        this.data = previous;
        return;
      }

      this.data = new Data();
      data.genericType = getter.getGenericReturnType();
      data.type = getter.getReturnType();
      // Compute collection element type
      if (Collection.class.isAssignableFrom(getType())) {
        data.elementType =
            TypeUtils.ensureBaseType(
                TypeUtils.getSingleParameterization(
                    Collection.class, getter.getGenericReturnType(), getter.getReturnType()));
      } else if (Map.class.isAssignableFrom(getType())) {
        Type[] types = TypeUtils.getParameterization(Map.class, getter.getGenericReturnType());
        data.keyType = TypeUtils.ensureBaseType(types[0]);
        data.valueType = TypeUtils.ensureBaseType(types[1]);
      }
      cache.put(getter, data);
    }
  }
Пример #19
0
 /** Test of initialize method, of class Activity. */
 @Test
 public void testInitialize_Activity_Map() throws Exception {
   System.out.println("initialize");
   // Setup
   ParentActivity parent = new ParentActivity();
   Data data = new Data();
   Map<Field, Object> fieldParams = new HashMap<Field, Object>();
   for (Field field : data.getClass().getDeclaredFields()) {
     field.setAccessible(true);
     fieldParams.put(field, field.get(data));
   }
   final String field2 = "field2value";
   final List<String> field3 = new ArrayList<String>();
   Map<String, Object> takeoverParams =
       new HashMap<String, Object>() {
         {
           put("field2", field2);
           put("field3", field3);
         }
       };
   ChildActivity child = new ChildActivity();
   child.initialize(parent, fieldParams, takeoverParams);
   // Assertion
   assertEquals(parent, child.getParent());
   assertEquals(data.getField0(), child.field0);
   assertEquals(data.getField1(), child.field1);
   assertEquals(field2, child.field2);
   assertEquals(field3, child.field3);
   assertEquals("TESTING", child.getTest());
 }
Пример #20
0
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }

    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    Data<Resource> that = ((Relationship) o).getData();

    if (that == null || data == null) {
      return that == data;
    }

    Collection<ResourceIdentifier> resourceIdentifiers = data.toResourceIdentifiers();
    Collection<ResourceIdentifier> theirIdentifiers = that.toResourceIdentifiers();

    for (ResourceIdentifier resourceIdentifier : resourceIdentifiers) {
      if (!theirIdentifiers.contains(resourceIdentifier)) {
        return false;
      }
    }
    return true;
  }
Пример #21
0
  public static void main(String[] args) throws FileNotFoundException {
    if (args.length < 1) {
      System.err.println("error: missing parameter: input file");
      System.err.println("usage: launch.sh input.in");
      System.exit(1);
    }

    String inputFileName = args[0];

    System.out.println("Output File Name: " + getOutputFileName(inputFileName));

    Data d = Parser.parse(inputFileName);

    for (int i = 0; i < d.turns; i++) {
      d.currentTurn = i;

      System.out.println(" Turn #" + i);

      d.drones.forEach(dr -> dr.update(d));
      // System.out.println(d);

    }

    Writer.writeInFile(getOutputFileName(inputFileName));
  }
  @OnAlias("selectedproject")
  public void select_story(TeamchatAPI api) {
    String[] Project = api.context().currentReply().getField("project_name").split("-");
    pid = Long.valueOf(Project[Project.length - 1]);
    String URL = "https://www.pivotaltracker.com/services/v5/projects/" + pid + "/stories";
    String URL_parameter = "";
    SendGet sg = new SendGet();
    Field field_story = null;
    try {
      String jsonData = sg.sendGet(URL, USER_AGENT, URL_parameter, pb.getAccess_token());

      Gson gson = new Gson();
      Data[] Story = gson.fromJson(jsonData, Data[].class);

      field_story = api.objects().select().name("story_name").label("Story");
      for (Data story : Story) {
        field_story.addOption(story.getName() + "-" + story.getId());
      }
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    api.perform(
        api.context()
            .currentRoom()
            .post(
                new PrimaryChatlet()
                    .setQuestion("Select story to be deleted")
                    .setReplyScreen(api.objects().form().addField(field_story))
                    .alias("deleteselectedstory")));
  }
Пример #23
0
  @Test
  public void testMomentFieldStats() {
    Field uniform = Data.makeColumnField("a", "label", new Object[] {100, 200, 300, 400, 500, 600});
    Field uniformWithMissing =
        Data.makeColumnField("a", "label", new Object[] {100, 200, null, 300, "a", 400, 500, 600});
    Field peak = Data.makeColumnField("b", "label", new Object[] {1, 2, 2, 2, 2, 2, 2, 3});
    Field skew = Data.makeColumnField("c", "label", new Object[] {1, 1, 1, 1, 1, 2, 2, 2, 5, 10});

    assertEquals(350, uniform.numericProperty("mean"), 0.01);
    assertEquals(350, uniformWithMissing.numericProperty("mean"), 0.01);
    assertEquals(2, peak.numericProperty("mean"), 0.01);
    assertEquals(2.6, skew.numericProperty("mean"), 0.01);

    assertEquals(187.08, uniform.numericProperty("stddev"), 0.01);
    assertEquals(187.08, uniformWithMissing.numericProperty("stddev"), 0.01);
    assertEquals(0.534, peak.numericProperty("stddev"), 0.01);
    assertEquals(2.875, skew.numericProperty("stddev"), 0.01);

    assertEquals(0, uniform.numericProperty("skew"), 0.01);
    assertEquals(0, uniformWithMissing.numericProperty("skew"), 0.01);
    assertEquals(0, peak.numericProperty("skew"), 0.01);
    assertEquals(1.86, skew.numericProperty("skew"), 0.01);

    assertEquals(-1.557, uniform.numericProperty("kurtosis"), 0.01);
    assertEquals(-1.557, uniformWithMissing.numericProperty("kurtosis"), 0.01);
    assertEquals(0.5, peak.numericProperty("kurtosis"), 0.01);
    assertEquals(1.983, skew.numericProperty("kurtosis"), 0.01);
  }
  public Object invoke(
      Object deployID,
      InterfaceType type,
      Class callInterface,
      Method callMethod,
      Object[] args,
      Object primKey)
      throws OpenEJBException {
    BeanContext beanContext = this.getBeanContext(deployID);

    if (beanContext == null)
      throw new OpenEJBException(
          "Deployment does not exist in this container. Deployment(id='"
              + deployID
              + "'), Container(id='"
              + containerID
              + "')");

    // Use the backup way to determine call type if null was supplied.
    if (type == null) type = beanContext.getInterfaceType(callInterface);

    Data data = (Data) beanContext.getContainerData();
    MethodType methodType = data.getMethodIndex().get(callMethod);
    methodType = (methodType != null) ? methodType : MethodType.BUSINESS;

    switch (methodType) {
      case CREATE:
        return createEJBObject(beanContext, callMethod, args, type);
      case REMOVE:
        return removeEJBObject(beanContext, primKey, callInterface, callMethod, args, type);
      default:
        return businessMethod(beanContext, primKey, callInterface, callMethod, args, type);
    }
  }
  /**
   * UC 5_1 Metode que calcula el preu final de la reserva, tenint en compte totes les possibles
   * penalitzacions. Tambe canvia el estat de la moto.
   */
  public void cobrarReserva() {
    String diaActual, horaActual;
    Consola.escriu("Introdueix la data 'actual' (dd/mm/aaaa):");
    diaActual = Consola.llegeixString();
    Consola.escriu("Introdueix la hora 'actual' (hh:mm:ss): ");
    horaActual = Consola.llegeixString();
    Data dataEntrega = Data.crearData(diaActual, horaActual);

    // Data dataEntrega = new Data(); //es pot seleccionar aquesta opcio si es vol fer automatic.

    float diferencia;
    clientReserva.setEstat("NO RESERVA");

    diferencia = dataEntrega.calcularDiferencia(dataFinal);

    if (diferencia > 0.0f) {
      penalitzacio = diferencia * 2;
      Consola.escriu("La moto s'ha entregat amb retras.\n La reserva tindra un preu adicional de ");
      Consola.escriu(penalitzacio);
      penalitzacioTemps = true;
      preu += penalitzacio;
      Consola.escriu("€ tinguent un preu final de ");
      Consola.escriu(preu);
      Consola.escriu("€.\n");
    }

    gestionarAveria();
  }
Пример #26
0
  @Override
  protected void onResume() {
    super.onResume();

    firstfix = true;
    if (!data.isRunning()) {
      Gson gson = new Gson();
      String json = sharedPreferences.getString("data", "");
      data = gson.fromJson(json, Data.class);
    }
    if (data == null) {
      data = new Data(onGpsServiceUpdate);
    } else {
      data.setOnGpsServiceUpdate(onGpsServiceUpdate);
    }

    if (mLocationManager.getAllProviders().indexOf(LocationManager.GPS_PROVIDER) >= 0) {
      mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 0, this);
    } else {
      Log.w(
          "MainActivity",
          "No GPS location provider found. GPS data display will not be available.");
    }

    if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
      showGpsDisabledDialog();
    }

    mLocationManager.addGpsStatusListener(this);
  }
Пример #27
0
  /**
   * parse URL to get encoded points and lines data it can be passed with or without host it should
   * start with '?' char ex. http://ipfx.org/?p=7ffffffe&l=09c287fff63d67fff or
   * ?p=7ffffffe&l=09c287fff63d67fff both will work
   *
   * @param url - data encoded in the url
   * @return
   */
  public static Interpolator parseUrl(String url) {

    Data data = Data.parseUrl(url);

    if (data != null) {

      ArrayList<Vector> points = new ArrayList<Vector>();
      points.addAll(data.getPoints());

      ArrayList<Line> lines = new ArrayList<Line>();

      int i = 0;
      for (Data.Line l : data.getLines()) {

        Vector p1 = points.get(i);
        Vector p2 = points.get(i + 1);

        Line line = Line.create(p1, p2, l.v1, l.v2, l.f);

        if (line == null) {
          return null;
        } else {
          lines.add(line);
        }

        i++;
      }

      return new Interpolator(points, lines);

    } else {
      return null;
    }
  }
Пример #28
0
  public static void main(final String[] args) throws Exception {
    for (int run = 0, numberOfThreads = 100; run < 1000; run++) {
      System.out.printf("Run %05d.....", run + 1);
      final Data data = new Data();

      final List<Thread> threads = new ArrayList<>(numberOfThreads);
      for (int i = 0; i < numberOfThreads; i++) {
        final Thread thread =
            new Thread(
                new Runnable() {
                  @Override
                  public void run() {
                    synchronized (data) {
                      final int value = data.getValue();
                      data.setValue(value + 1);
                    }
                  }
                });
        thread.start();
        threads.add(thread);
      }

      for (final Thread thread : threads) {
        thread.join();
      }

      if (data.getValue() == numberOfThreads) {
        System.out.println("Passed");
      } else {
        System.out.printf("Failed with value %d instead of %d%n", data.getValue(), numberOfThreads);
        break;
      }
    }
  }
Пример #29
0
    protected void onPostExecute(String result) {

      name.setText(eventInformationPage.returneventinfo().getName());

      String temp1 = eventInformationPage.returneventinfo().getStartDay();
      String format1 =
          temp1.substring(0, 2) + "/" + temp1.substring(2, 4) + "/" + temp1.substring(4, 8);

      String temp2 = eventInformationPage.returneventinfo().getEndDay();
      String format2 =
          temp2.substring(0, 2) + "/" + temp2.substring(2, 4) + "/" + temp2.substring(4, 8);

      if (eventInformationPage
          .returneventinfo()
          .getStartDay()
          .equals(eventInformationPage.returneventinfo().getEndDay())) {
        Data.setText("Data: " + format1);
      } else {

        Data.setText("Date: " + format1 + " -- " + format2);
      }

      Day.setText("Day: " + eventInformationPage.returneventinfo().getDay());

      location.setText("Location: " + eventInformationPage.returneventinfo().getLocation());

      time.setText(
          "Time: "
              + eventInformationPage.returneventinfo().getStartTime()
              + "-"
              + eventInformationPage.returneventinfo().getEndTime());

      pd.dismiss();
    }
Пример #30
0
 public void setWarlockSCFocus(Data warlockSCFocus) {
   warlockSCFocus.abilName = "Spellcasting Focus";
   warlockSCFocus.dlevel = 1;
   warlockSCFocus.dClass = "Warlock";
   warlockSCFocus.flavor =
       "You can use an arcane focus (found in chapter 5) as a spellcasting focus for your warlock spells.\n";
 }