コード例 #1
0
ファイル: Clock.java プロジェクト: Moda-dev/TLWTM
  public static void main(String[] args) {
    // on initialise un objet clock
    Clock hms = new Clock(15, 55, 59);

    // test des Getters
    System.out.println("Test des Getters :");
    System.out.println(hms.getHours());
    System.out.println(hms.getMinutes());
    System.out.println(hms.getSeconds());

    // test de la conversion en secondes
    System.out.println("Test de la conversion en secondes :");
    int seconds = 0;
    seconds = hms.convert2seconds();
    System.out.println(seconds);

    // test de l'incrémentation.
    System.out.println("Test de l'incrémentation :");
    String toStrong;
    hms.increments();
    toStrong = hms.toString();
    System.out.println(toStrong);

    // test du reset.
    System.out.println("Test du reset :");
    hms.reset();
    toStrong = hms.toString();
    System.out.println(toStrong);
  }
コード例 #2
0
ファイル: NodeUtil.java プロジェクト: brownman/EasyGoGui
 /**
  * Restore the clock to the state corresponding to a node. Updates the clock from the time left
  * information stored in the nodes of the sequence from the root node to the current node.
  *
  * @param node The current node.
  * @param clock The clock to update.
  */
 public static void restoreClock(ConstNode node, Clock clock) {
   clock.reset();
   ArrayList<ConstNode> path = new ArrayList<ConstNode>();
   getPathToRoot(node, path);
   for (int i = path.size() - 1; i >= 0; --i) {
     ConstNode pathNode = path.get(i);
     restoreTimeLeft(pathNode, clock, BLACK);
     restoreTimeLeft(pathNode, clock, WHITE);
   }
 }
コード例 #3
0
ファイル: Timer.java プロジェクト: singlow/bramblecriste
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_reset:
       clock.reset();
       break;
     case R.id.menu_settings:
       Intent settings = new Intent(this, Preferences.class);
       startActivity(settings);
       break;
   }
   return super.onOptionsItemSelected(item);
 }
コード例 #4
0
ファイル: SignalPhase.java プロジェクト: elenadorogush/sirius
  protected void reset() {

    hasstoplinecall = false;
    hasapproachcall = false;
    hasconflictingcall = false;
    conflictingcalltime = 0f;
    hold_requested = false;
    forceoff_requested = false;
    permithold = true;
    permitopposinghold = false;

    setPhaseColor(Signal.BulbColor.RED);
    bulbtimer.reset();
  }
コード例 #5
0
ファイル: SnakeGame.java プロジェクト: GuitarBA/SnakeRemake
  /** Resets the game's variables to their default states and starts a new game. */
  private void resetGame() {
    /*
     * Reset the score statistics. (Note that nextFruitPoints is reset in
     * the spawnFruit function later on).
     */
    this.score = 0;
    this.fruitsEaten = 0;

    /*
     * Reset both the new game and game over flags.
     */
    this.isNewGame = false;
    this.isGameOver = false;

    /*
     * Create the head at the center of the board.
     */
    Point head = new Point(BoardPanel.COL_COUNT / 2, BoardPanel.ROW_COUNT / 2);

    /*
     * Clear the snake list and add the head.
     */
    snake.clear();
    snake.add(head);

    /*
     * Clear the board and add the head.
     */
    board.clearBoard();
    board.setTile(head, TileType.SnakeHead);

    /*
     * Clear the directions and add north as the
     * default direction.
     */
    directions.clear();
    directions.add(Direction.North);

    /*
     * Reset the logic timer.
     */
    logicTimer.reset();

    /*
     * Spawn a new fruit.
     */
    spawnFruit();
  }
コード例 #6
0
ファイル: SignalPhase.java プロジェクト: elenadorogush/sirius
  protected void update(boolean hold_approved, boolean forceoff_approved) {
    double bulbt = bulbtimer.getT();

    if (!protectd) {
      if (permissive) return;
      else {
        setPhaseColor(Signal.BulbColor.RED);
        return;
      }
    }

    // execute this state machine until "done". May be more than once if
    // some state has zero holding time (eg yellowtime=0)
    boolean done = false;

    while (!done) {

      switch (bulbcolor) {

          // .............................................................................................
        case GREEN:
          setPhaseColor(Signal.BulbColor.GREEN);

          //				permitopposinghold = false;

          // Force off
          if (forceoff_approved) {
            setPhaseColor(Signal.BulbColor.YELLOW);
            mySignal.completedPhases.add(
                mySignal
                .new PhaseData(
                    myNEMA, mySignal.myScenario.clock.getT() - bulbtimer.getT(), bulbtimer.getT()));
            bulbtimer.reset();
            // FlushAllStationCallsAndConflicts();
            done = actualyellowtime > 0;
          } else done = true;

          break;

          // .............................................................................................
        case YELLOW:
          setPhaseColor(Signal.BulbColor.YELLOW);

          // set permitopposinghold one step ahead of time so that other phases update correctly
          // next time.
          //				permitopposinghold = false;

          //				if( SiriusMath.greaterorequalthan(bulbt,actualyellowtime-bulbtimer.dt) &&
          // redcleartime==0)
          //					permitopposinghold = true;

          // yellow time over, go immediately to red if redcleartime==0
          if (SiriusMath.greaterorequalthan(bulbt, actualyellowtime)) {
            setPhaseColor(Signal.BulbColor.RED);
            bulbtimer.reset();
            done = redcleartime > 0;
          } else done = true;
          break;

          // .............................................................................................
        case RED:
          setPhaseColor(Signal.BulbColor.RED);

          // if(
          // SiriusMath.greaterorequalthan(bulbt,redcleartime-myNode.getMyNetwork().getTP()*3600f
          // && !goG )
          //				if( SiriusMath.greaterorequalthan(bulbt,redcleartime-bulbtimer.dt) && !hold_approved
          // )
          //					permitopposinghold = true;
          //				else
          //					permitopposinghold = false;

          // if hold, set to green, go to green, etc.
          if (hold_approved) {
            setPhaseColor(Signal.BulbColor.GREEN);
            bulbtimer.reset();

            // Unregister calls (for reading conflicting calls)
            // FlushAllStationCallsAndConflicts(); // GCG ?????

            done = !forceoff_approved;
          } else done = true;

          break;
      }
    }
  }