Exemplo n.º 1
0
 /**
  * Prints the motos of a list.
  *
  * @param aux list to be printed out.
  */
 private void printMotoList(ArrayList<Moto> aux) {
   int i = 0;
   for (Moto m : aux) {
     Consola.escriu("Moto " + Integer.toString(i + 1));
     Consola.escriu("****************");
     m.printInfoMoto();
     Consola.escriu("****************");
     i++;
   }
 }
Exemplo n.º 2
0
  /**
   * Prints a certain information about the book.
   *
   * @param localS
   * @param localE
   * @param motoreta
   * @param date
   * @param cantDias
   * @param cantHoras
   */
  private void bookPrintInfo(
      Local localS, Local localE, Moto motoreta, Calendar date, int cantDias, int cantHoras) {
    String strDays;
    String strHours;

    localS.printInfoLocal();
    localE.printInfoLocal();
    motoreta.printInfoMoto();

    Consola.escriu("Time to reserve");
    strDays = Integer.toString(cantDias);
    strHours = Integer.toString(cantHoras);
    Consola.escriu("Days:" + strDays + "Hours:" + strHours);
  }
Exemplo n.º 3
0
  /** Method that allows the admin to see all the motos. */
  private void seeMotos() {
    int i = 0;
    // Print the motos located in locals.
    for (Local l : lstLocal) {
      // First, let the admin know in which local are the motos.
      i++;
      Consola.escriu("------------");
      Consola.escriu("Local " + i);
      l.printInfoLocal();
      Consola.escriu("------------");
      // Second, lets print all the motos
      Consola.escriu("Motos being driven");
      l.printMotoList();
    }

    // Print the motos currently being driven.
    Consola.escriu("Motos currently on the road: ");
    for (Moto m : lstDriving) {
      m.printInfoMoto();
    }
  }
Exemplo n.º 4
0
  /** The admin is allowed to switch motos between some locals. */
  private void adminMoto() {
    Moto m;
    Local lStart, lEnd;
    Boolean bool = true;
    ArrayList lstLocal;
    int size, num;
    String answer;

    /**
     * TO DO: Si las listas están vacías, hay que salir de la opción porque no se pueden mover
     * motos.
     */

    // We will do this until the admin doesn't want to move more motos.
    while (bool) {
      // From which locals can we move motos? Take them and put them in a list.
      lstLocal = getStartAvailableLocals();
      // Same error control here. If the locals are empty, we can't move anything!
      if (!lstLocal.isEmpty()) {
        Consola.escriu("\n You can move motos from these locals: ");
        printLocalList(lstLocal);
        Consola.escriu("\n Insert the number of the index of your prefered local");
        num = Consola.llegeixInt();
        size = lstLocal.size();
        // Let's check if the index inserted is correct:
        num = checkNumber(num, size);
        lStart = getLocalByIndex(lstLocal, num);

        // Obtain the moto the admin wants to move:
        Consola.escriu("\n --->These are the motos you can move: ");
        lStart.printMotoList();
        Consola.escriu("\n Insert the number of the index of the moto you want to move: ");
        num = Consola.llegeixInt();
        size = lStart.getQuantityMotos();
        // Check that the index is correct
        num = checkNumber(num, size);
        m = lStart.getMotoByIndex(num);

        // To which locals can we move motos? Take them and put them in list.
        lstLocal = getEndAvailableLocals();
        if (!lstLocal.isEmpty()) {
          Consola.escriu("\n You can move motos to these locals: ");
          printLocalList(lstLocal);
          Consola.escriu("\n Insert the number of the index of your prefered local");
          num = Consola.llegeixInt();
          size = lstLocal.size();
          // Let's check if the index inserted is correct:
          num = checkNumber(num, size);
          lEnd = getLocalByIndex(lstLocal, num);

          /** LOTS of prints!! */
          Consola.escriu("*********************");
          Consola.escriu("These are the changes you are about to do: ");
          Consola.escriu("*********************");

          Consola.escriu("\n You will move a moto from the local: ");
          lStart.printInfoLocal();

          Consola.escriu("*********************");

          Consola.escriu("\n You will move the moto: ");
          m.printInfoMoto();

          Consola.escriu("*********************");

          Consola.escriu("\n You will move the moto to the local: ");
          lEnd.printInfoLocal();

          Consola.escriu("*********************");

          Consola.escriu("Insert an S to confirm the changes or an N to discard them ");
          answer = Consola.llegeixString();
          // Let's check if the admin wants to confirm the changes.
          // If we have a true, we keep doing it.
          // If we have a false, the admin doesn't want to make changes.
          bool = checkYesNo(answer);
          if (bool) {
            changeMoto(lStart, lEnd, m);

            Consola.escriu("\n *** The change has been done correctly! ***");
            Consola.escriu("Insert an S to keep moving motos, an N otherwise");
            answer = Consola.llegeixString();
            // Same scenario here. If we have a true, the admin wants to make more changes.
            bool = checkYesNo(answer);
          }
        } else {
          Consola.escriu("Sorry, but you can't move motos right now. Your locals are almost full.");
        }
      } else {
        Consola.escriu("Sorry, but you can't move motos right now. Your locals are almost empty.");
      }
    }
  }