Example #1
0
 public Exercise retrieveRecord(int id) {
     for (Exercise member : myList) {
         if (member.getId() == id) {
             return member;
         }
     }
     return null;
 }
Example #2
0
 public void deleteRecord(int id) {
     for (Exercise member : myList) {
         if (member.getId() == id) {
             myList.remove(member);
             break;
         }
     }
     writeList();
 }
  @Override
  public void onEdit(Exercise exercise, int position) {
    if (position == -1) {
      for (Exercise e : workout.getExercises()) {
        String name = e.getName();
        if (name.equals(exercise.getName())) {
          Toast toast = Toast.makeText(this, "Exercise already exists!", Toast.LENGTH_SHORT);
          toast.setGravity(Gravity.CENTER, 0, 0);
          toast.show();
          return;
        }
      }
    }
    ArrayList<Integer> positions = adapter.getCursorPositions();
    MatrixCursor newcursor = new MatrixCursor(new String[] {"_id", "name"});
    // int lastCursorPosition = cursor.getPosition();
    // copy over old cursor items to the new one.
    if (cursor != null) {
      cursor.moveToFirst();
      for (int i = 0; i < positions.size(); i++) {
        int cursorPosition = positions.get(i);
        int listPosition = adapter.getListPosition(positions.get(i));
        // dont add to new cursor if item has been removed.
        if (listPosition == DragSortCursorAdapter.REMOVED) continue;
        cursor.moveToPosition(cursorPosition);
        String c = cursor.getString(1);
        // if its not a new exercise, check to see if the current cursor list position mapping
        // matches the one we are working with. If yes, set c to be the new exercise.
        if (position >= 0) {
          if (position == listPosition) {
            c = exercise.getName();
          }
        }
        newcursor.newRow().add(listPosition).add(c);
      }
    }
    // add the new row
    if (position < 0 && exercise != null) {
      newcursor.newRow().add(newcursor.getCount()).add(exercise.getName());
    }

    ArrayList<Exercise> newExercises = new ArrayList<Exercise>();
    newcursor.moveToFirst();
    for (int i = 0; i < newcursor.getCount(); i++) {
      String ename = newcursor.getString(1);
      Exercise e = workout.getExercise(ename);
      if (e != null) newExercises.add(e);
      else if (i == newcursor.getCount() - 1) newExercises.add(exercise);
      if (!newcursor.moveToNext()) break;
    }

    adapter.changeCursor(newcursor);
    cursor = newcursor;

    // modify workout to reflect the change
    workout.setExercises(newExercises);
  }
  @Override
  public void onClick(View v) {
    Log.d("mine", "onClick");

    switch (v.getId()) {
      case R.id.newExerciseOK:

        // get the data newExerciseName
        String name = etName.getText().toString();
        Exercise exercise = new Exercise();
        exercise.setExerciseName(name);

        // TODO: for now take only one selection, future = multiple
        SparseBooleanArray checked = mTypeListView.getCheckedItemPositions();
        ArrayList<String> selectedItems = new ArrayList<String>();
        for (int i = 0; i < checked.size(); i++) {
          // Item position in adapter
          int position = checked.keyAt(i);
          // Add sport if it is checked i.e.) == TRUE!
          if (checked.valueAt(i)) selectedItems.add(mTypeArrayAdapter.getItem(position));
        }

        String[] outputStrArr = new String[selectedItems.size()];

        for (int i = 0; i < selectedItems.size(); i++) {
          outputStrArr[i] = selectedItems.get(i);
          Log.d("mine", outputStrArr[i]);
          String type = outputStrArr[i];
          exercise.setExerciseType(type);
        }

        // validate entry

        // create Exercise Object

        // Toast.makeText(this.getActivity(),"hi",Toast.LENGTH_LONG).show();

        // return object
        mListener.onDialogPositiveClick(exercise);
        break;

      case R.id.newExerciseCancel:
        mListener.onDialogNegativeClick();
        this.dismiss();
        break;
        //            case R.id.button_three:
        //                // i'm lazy, do nothing
        //                break;
    }

    this.dismiss();
  }
Example #5
0
 public void save(PrintWriter outFile) {
   outFile.println(name);
   outFile.println(creation.getTimeInMillis());
   if (viewed == null) {
     outFile.println(nullStr);
   } else {
     outFile.println(viewed.getTimeInMillis());
   }
   if (used == null) {
     outFile.println(nullStr);
   } else {
     outFile.println(used.getTimeInMillis());
   }
   for (Exercise ex : exercises) {
     outFile.println();
     ex.save(outFile);
   }
   outFile.println(endWorkout);
 }
  public View getView(int position, View convertView, ViewGroup parent) {
    View row = super.getView(position, convertView, parent);
    TextView exerciseName = (TextView) row.findViewById(R.id.name_in_row);
    // set the text view text to the exercise name
    exerciseName.setText(exercises.get(position).getName());
    TextView exerciseTime = (TextView) row.findViewById(R.id.time_in_row);
    // set the text view text to the exercise time, while formatting it
    exerciseTime.setText(Exercise.timeToString(exercises.get(position).getTime()));

    return row;
  }
Example #7
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder;
    if (convertView == null) {
      convertView =
          View.inflate(this.getContext(), R.layout.main_trainingschedule_overview_exercise, null);
      viewHolder = new ViewHolder();
      viewHolder.poseView =
          (ImageView) convertView.findViewById(R.id.main_trainingschedule_workout_type);
      viewHolder.nameView =
          (TextView) convertView.findViewById(R.id.main_trainingschedule_workout_name);

      convertView.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }

    Exercise exercise = this.exercises.get(position);
    viewHolder.poseView.setImageResource(this.exerciseIcons[exercise.getWorkoutType() - 1]);
    viewHolder.nameView.setText(exercise.getName());

    return convertView;
  }
Example #8
0
 protected void writeList() {
     Path path = Paths.get(fileName);
     try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
         for (Exercise member : myList) {
             writer.write(String.format("%d,%s,%s,%s,%.2f\n",
                     member.getId(),
                     member.getMemberNumber(),
                     member.getexcerciseType(),
                     member.getDate(),
                     member.getTime(),
                     member.getComments());
         }
     } catch (IOException ioe) {
         System.out.println("Write file error with " + ioe.getMessage());
     }
 }
Example #9
0
  public static void runFromCsv(String csvFile) throws IOException {
    List<String[]> exercises;
    try (CSVReader reader = new CSVReader(new FileReader(csvFile))) {
      exercises = reader.readAll();
    }

    while (true) {
      for (String[] exercise : exercises) {
        if (exercise.length < 2) continue;

        if (exercise[0].startsWith("#")) continue;

        LOGGER.info("Running {} for {}", exercise[0], exercise[1]);
        String[] arguments = Arrays.copyOfRange(exercise, 2, exercise.length);
        Exercise.runExercise(exercise[0], Long.parseLong(exercise[1]), arguments);
      }
    }
  }
Example #10
0
  public static void main(String[] args) throws ParseException, IOException {
    Options options = new Options();
    options.addOption("f", true, "csv file to use for exercises");
    options.addOption("c", true, "single class to run");
    options.addOption("t", true, "time limit to run for");

    CommandLine cmd = new GnuParser().parse(options, args);

    if (cmd.hasOption("f")) {
      runFromCsv(cmd.getOptionValue("f"));
    } else if (cmd.hasOption("c")) {
      String exercise = cmd.getOptionValue("c");
      long timeLimit = Long.parseLong(cmd.getOptionValue("t"));
      Exercise.runExercise(exercise, timeLimit, new String[0]);
    } else {
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("Main", options);
    }
  }
Example #11
0
 public static Workout load(BufferedReader inFile, int key) throws IOException {
   Workout rv = new Workout(inFile.readLine(), Long.parseLong(inFile.readLine()));
   String line = inFile.readLine();
   if (line.compareTo(nullStr) != 0) {
     rv.viewed = Calendar.getInstance();
     rv.viewed.setTimeInMillis(Long.parseLong(line));
   }
   line = inFile.readLine();
   if (line.compareTo(nullStr) != 0) {
     rv.used = Calendar.getInstance();
     rv.used.setTimeInMillis(Long.parseLong(line));
   }
   line = inFile.readLine();
   while (line != null && line.compareTo(endWorkout) != 0) {
     rv.exercises.add(Exercise.load(inFile));
     line = inFile.readLine();
   }
   rv.key = key;
   return rv;
 }
Example #12
0
 public History(Exercise ex, Context context) {
   this.exercise = ex;
   this.fkExercises = ex.getId();
   openDB(context, false);
   try {
     Cursor c =
         myHelper.getData(
             "select * from 't_history' where _id=(select max(_id) from 't_history' where FK_Exercise='"
                 + String.valueOf(this.fkExercises)
                 + "')");
     c.moveToFirst();
     this.value = c.isNull(c.getColumnIndex("Value")) ? 0 : c.getFloat(c.getColumnIndex("Value"));
     this.sets = c.isNull(c.getColumnIndex("Sets")) ? 0 : c.getInt(c.getColumnIndex("Sets"));
     this.iterations =
         c.isNull(c.getColumnIndex("Iterations")) ? 0 : c.getInt(c.getColumnIndex("Iterations"));
     c.close();
   } catch (CursorIndexOutOfBoundsException n) {
     this.value = 0;
     this.sets = 0;
     this.iterations = 0;
   } finally {
     myHelper.close();
   }
 }
 public Exercise generate(ExerciseTemplate exerciseTemplate) {
   Exercise exercise = new Exercise();
   exercise.setClusters(generateClusterQuestions(exerciseTemplate));
   exercise.setType(exerciseTemplate.getType());
   return exercise;
 }
Example #14
0
  public Exercise removeExercis(Exercise exercis) {
    getExercises().remove(exercis);
    exercis.setLessonBean(null);

    return exercis;
  }
Example #15
0
  public Exercise addExercis(Exercise exercis) {
    getExercises().add(exercis);
    exercis.setLessonBean(this);

    return exercis;
  }
Example #16
0
    @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

      // BROWSE STATES
      final int NOT_BROWSE = 0, BROWSE_WORKOUT = 1, WORKOUT_BROWSE = 2;

      if ((convertView == null)) {
        convertView = getLayoutInflater().inflate(R.layout.b_frag_exercise_list_item, null);
      }

      final SwipableLinearLayout swipableLinearLayout =
          (SwipableLinearLayout) convertView.findViewById(R.id.swipeLayoutHandle);
      swipableLinearLayout.setSwipeOffset(slideVal);
      swipableLinearLayout.setSwipeLayoutListener(listener);
      swipableLinearLayout.percentageToDragEnable(75f);

      final Exercise e = getItem(position);
      TextView nameTextView = (TextView) convertView.findViewById(R.id.browseMenuExerciseNameView);
      nameTextView.setText(e.getName());
      TextView muscleTextView =
          (TextView) convertView.findViewById(R.id.browseMenuExerciseMuscleView);
      muscleTextView.setText(e.getMuscleGroup());
      TextView equipmentTextView =
          (TextView) convertView.findViewById(R.id.browseMenuExerciseEquip);
      equipmentTextView.setText(e.getEquipment());

      if (swipableLinearLayout.getX() != 0) {
        swipableLinearLayout.setX(0f);

        if (mTextViewHandle != null) mTextViewHandle.setOpen(false);

        mTextViewHandle = null;
      }
      swipableLinearLayout.refreshIcon();

      swipableLinearLayout.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              /*
              Exercise exercise = new Exercise();
              exercise.setName(e.getName());
              exercise.setId(e.getId());
              //Stubs
              //exercise.instantiateStubMetrics();
              for (Metric m : e.getMetrics()){
                  Metric nm = new Metric();
                  nm.setType(m.getType());
                  nm.setMetricIntValue(m.getMetricIntValue());
                  exercise.addMetrics(nm);
              }

              WorkoutData.get(mContext).setToggledExerciseExplicit(e);//Sets this as the 'last' item added

              int circuitValue = WorkoutData.get(mContext).getStateCircuit();
              boolean circuitOpenStatus = WorkoutData.get(mContext).isStateCircuitOpen();
              //if circuit is open
              if (circuitOpenStatus) {
                  //addToOpenCircuit to that circuit
                  WorkoutData.get(mContext).addExerciseToOpenCircuit(exercise,
                         circuitValue);
                  //if circuit is closed
              } else if (!circuitOpenStatus) {
                  //add a closed circuit, with the exercise in it
                  WorkoutData.get(mContext).addClosedCircuit(exercise,
                          circuitValue);
              }
              //return to workspace
              */
              WorkoutData.get(mContext).swap(e);
              WorkoutData.get(mContext).setBrowseState(BROWSE_WORKOUT);
              Intent i = new Intent(mContext, WorkspaceActivity.class);
              startActivity(i);
            }
          });

      ImageButton delete = (ImageButton) convertView.findViewById(R.id.deleteButton);
      delete.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {

              WorkoutData.get(mContext).exerciseRemoved(e.getId());
              DatabaseWrapper db = new DatabaseWrapper();
              db.deleteExerciseInExerciseTable(e.getId());
              mExercises.remove(e);
              notifyDataSetChanged();
              /*
              if(WorkoutData.get(mContext).isAnExerciseToggled()){
                  if (WorkoutData.get(mContext).getToggledExercise() == e){
                      WorkoutData.get(mContext).clearToggledExercise();
                  }
              }
              */
            }
          });

      return convertView;
    }
Example #17
0
 public void updateRecord(Exercise updatedExercise) {
     for (Exercise member : myList) {
         if (member.getId() == updatedExercise.getId()) {
             member.setMemberNumber(updatedExercise.getMemberNumber());
             member.setexcerciseType(updatedExercise.getexcerciseType());
             member.setDate(updatedExercise.getDate());
             member.setTime(updatedExercise.getTime());
             break;
         }
     }
     writeList();
 }
Example #18
0
 public void makeHistory(boolean duringWorkout) {
   for (Exercise ex : exercises) {
     ex.makeHistory(duringWorkout);
   }
 }
Example #19
0
  public static void main(String[] args) {

    System.out.println(
        "\n-----------------------\n  Welcome in B.M.G. !\n-----------------------\n");

    while (true) {
      Scanner sc = new Scanner(System.in);
      System.out.println("1 - Calculation part");
      System.out.println("2 - Fraction part");
      System.out.println("3 - Equation part");
      System.out.println("4 - Custom part");
      System.out.println("5 - Power part");
      System.out.println("6 - Save/Load part");
      System.out.println("7 - Practice part");
      int sel = sc.nextInt();
      switch (sel - 1) {
        case 0:
          System.out.println("-------> A random calculation <-------");
          QuestionCalculation qc1 = new QuestionCalculation();
          qc1.generate();
          System.out.println(qc1.getText());
          double res1 = qc1.solve();
          System.out.println("Result1: " + res1);
          System.out.println(
              "---------------------------------------------------------------------\n");

          System.out.println("\n-------> A calculation with a given length <-------");
          sc = new Scanner(System.in);
          System.out.print("Length? ");
          int l = sc.nextInt();
          QuestionCalculation qc2 = new QuestionCalculation();
          qc2.generate(l);
          System.out.println(qc2);
          double res2 = qc2.solve();
          System.out.println("Result2: " + res2);
          System.out.println(
              "---------------------------------------------------------------------\n");

          System.out.println("\n-------> A calculation with selected operators <-------");
          sc = new Scanner(System.in);
          char op = '+';
          ArrayList<Character> operators = new ArrayList<Character>();
          while (op != '0') {
            System.out.print("Operator? ");
            op = sc.next().charAt(0);
            if (op != '0') {
              operators.add(op);
            }
          }
          QuestionCalculation qc3 = new QuestionCalculation();
          qc3.generate(operators);
          System.out.println(qc3);
          double res3 = qc3.solve();
          System.out.println("Result3: " + res3);
          System.out.println(
              "---------------------------------------------------------------------\n");

          System.out.println(
              "\n-------> A calculation with selected operators and given length <-------");
          sc = new Scanner(System.in);
          System.out.print("Length? ");
          int l2 = sc.nextInt();
          char op2 = '+';
          ArrayList<Character> operators2 = new ArrayList<Character>();
          while (op2 != '0') {
            System.out.print("Operator? ");
            op2 = sc.next().charAt(0);
            if (op2 != '0') {
              operators2.add(op2);
            }
          }
          QuestionCalculation qc4 = new QuestionCalculation();
          qc4.generate(operators2, l2);
          System.out.println(qc4);
          double res4 = qc4.solve();
          System.out.println("Result4: " + res4);
          System.out.println(
              "---------------------------------------------------------------------\n");

          System.out.println("\n-------> An exercise with these questions <-------");
          Exercise ex1 = new Exercise("calculation");
          ex1.setWording(new Wording());
          ex1.addQuestion(qc1);
          ex1.addQuestion(qc2);
          ex1.addQuestion(qc3);
          ex1.addQuestion(qc4);
          ex1.exportToFile();
          System.out.println(ex1);
          System.out.println(
              "---------------------------------------------------------------------\n");

          System.out.println("\n-------> An exercise with a given type <-------");
          System.out.println("Type? ");
          String t = sc.next();
          System.out.println("");
          Exercise ex2 = new Exercise(t);
          ex2.generate();
          System.out.println(ex2);
          System.out.println(
              "---------------------------------------------------------------------\n");

          break;
        case 1:
          System.out.println("-------> A random question with fractions <-------");
          QuestionFraction qf1 = new QuestionFraction();
          qf1.generate();
          System.out.println(qf1);
          double res1f = qf1.solve();
          System.out.println("Result1: " + res1f);
          System.out.println(
              "---------------------------------------------------------------------\n");

          System.out.println("\n-------> A question with fractions with a given length <-------");
          sc = new Scanner(System.in);
          System.out.print("Length? ");
          int lf = sc.nextInt();
          QuestionFraction qf2 = new QuestionFraction();
          qf2.generate(lf);
          System.out.println(qf2);
          double res2f = qf2.solve();
          System.out.println("Result2: " + res2f);
          System.out.println(
              "---------------------------------------------------------------------\n");

          System.out.println(
              "\n-------> A question with fractions with selected operators <-------");
          sc = new Scanner(System.in);
          char opf = '+';
          ArrayList<Character> operatorsf = new ArrayList<Character>();
          while (opf != '0') {
            System.out.print("Operator? ");
            opf = sc.next().charAt(0);
            if (opf != '0') {
              operatorsf.add(opf);
            }
          }
          QuestionFraction qf3 = new QuestionFraction();
          qf3.generate(operatorsf);
          System.out.println(qf3);
          double res3f = qf3.solve();
          System.out.println("Result3: " + res3f);
          System.out.println(
              "---------------------------------------------------------------------\n");

          System.out.println(
              "\n-------> A question with fractions with selected operators and given length <-------");
          sc = new Scanner(System.in);
          System.out.print("Length? ");
          int l2f = sc.nextInt();
          char op2f = '+';
          ArrayList<Character> operators2f = new ArrayList<Character>();
          while (op2f != '0') {
            System.out.print("Operator? ");
            op2f = sc.next().charAt(0);
            if (op2f != '0') {
              operators2f.add(op2f);
            }
          }
          QuestionFraction qf4 = new QuestionFraction();
          qf4.generate(operators2f, l2f);
          System.out.println(qf4);
          double res4f = qf4.solve();
          System.out.println("Result4: " + res4f);
          System.out.println(
              "---------------------------------------------------------------------\n");

          System.out.println("\n-------> An exercise with these questions <-------");
          Exercise ex1f = new Exercise("fraction");
          ex1f.setWording(new Wording());
          ex1f.addQuestion(qf1);
          ex1f.addQuestion(qf2);
          ex1f.addQuestion(qf3);
          ex1f.addQuestion(qf4);
          System.out.println(ex1f);
          System.out.println(
              "---------------------------------------------------------------------\n");

          System.out.println("\n-------> An exercise with a given type <-------");
          System.out.println("Type? ");
          String tf = sc.next();
          System.out.println("");
          Exercise ex2f = new Exercise(tf);
          ex2f.generate();
          System.out.println(ex2f);
          System.out.println(
              "---------------------------------------------------------------------\n");

          break;
        case 2:
          System.out.println("-------> A random equation <-------");
          QuestionEquation qe1 = new QuestionEquation();
          sc = new Scanner(System.in);
          char opcu = '+';
          ArrayList<Character> operatorscu = new ArrayList<Character>();
          while (opcu != '0') {
            System.out.print("Operator? ");
            opcu = sc.next().charAt(0);
            if (opcu != '0') {
              operatorscu.add(opcu);
            }
          }
          qe1.generate(1, operatorscu);
          System.out.println(qe1);
          double[] res1e = qe1.solve();
          System.out.println("Result1: " + res1e[0]);
          System.out.println(
              "---------------------------------------------------------------------\n");

          System.out.println("\n-------> An equation with a given length <-------");
          sc = new Scanner(System.in);
          // System.out.print("Length? ");
          // int le = sc.nextInt();
          QuestionEquation qe2 = new QuestionEquation();
          qe2.generate(2, operatorscu);
          System.out.println(qe2);
          double[] res2e = qe2.solve();
          if (res2e.length > 1) {
            System.out.println("Result2(x1): " + res2e[0]);
            System.out.println("Result2(x2): " + res2e[1]);
          } else {
            System.out.println("Result2: " + res2e[0]);
          }
          System.out.println(
              "---------------------------------------------------------------------\n");
          /*
          System.out.println("\n-------> A question with fractions with selected operators <-------");
          sc = new Scanner(System.in);
          char opf = '+';
          ArrayList<Character> operatorsf = new ArrayList<Character>();
          while (opf != '0') {
          System.out.print("Operator? ");
          opf = sc.next().charAt(0);
          if (opf != '0') {
          operatorsf.add(opf);
          }
          }
          QuestionFraction qf3 = new QuestionFraction();
          qf3.generate(operatorsf);
          System.out.println(qf3);
          double res3f = qf3.solve();
          System.out.println("Result3: " + res3f);
          System.out.println("---------------------------------------------------------------------\n");

          System.out.println("\n-------> A question with fractions with selected operators and given length <-------");
          sc = new Scanner(System.in);
          System.out.print("Length? ");
          int l2f = sc.nextInt();
          char op2f = '+';
          ArrayList<Character> operators2f = new ArrayList<Character>();
          while (op2f != '0') {
          System.out.print("Operator? ");
          op2f = sc.next().charAt(0);
          if (op2f != '0') {
          operators2f.add(op2f);
          }
          }
          QuestionFraction qf4 = new QuestionFraction();
          qf4.generate(operators2f, l2f);
          System.out.println(qf4);
          double res4f = qf4.solve();
          System.out.println("Result4: " + res4f);
          System.out.println("---------------------------------------------------------------------\n");

          System.out.println("\n-------> An exercise with these questions <-------");
          Exercise ex1f = new Exercise("fraction");
          ex1f.setWording(new Wording());
          ex1f.addQuestion(qf1);
          ex1f.addQuestion(qf2);
          ex1f.addQuestion(qf3);
          ex1f.addQuestion(qf4);
          System.out.println(ex1f);
          System.out.println("---------------------------------------------------------------------\n");

          System.out.println("\n-------> An exercise with a given type <-------");
          System.out.println("Type? ");
          String tf = sc.next();
          System.out.println("");
          Exercise ex2f = new Exercise(tf);
          ex2f.generate();
          System.out.println(ex2f);
          System.out.println("---------------------------------------------------------------------\n");*/

          break;
        case 3:
          System.out.println("-------> A custom question <-------");
          QuestionCustom qcu = null;
          sc = new Scanner(System.in);
          System.out.println("Wording ?");
          String tcu = sc.nextLine();
          System.out.println("Solution type ?\n1- int\n2- double\n3- string");
          int i = new Integer(sc.next());
          if (i == 1) {
            int sol = new Integer(sc.next());
            qcu = new QuestionCustom<Integer>(tcu, sol);
          }
          if (i == 2) {
            Double[] sol = {new Double(sc.next())};
            qcu = new QuestionCustom<Double>(tcu, sol);
          }
          if (i == 3) {
            String[] sol = {sc.nextLine()};
            qcu = new QuestionCustom<String>(tcu, sol);
          }
          System.out.println(qcu);
          System.out.println(
              "---------------------------------------------------------------------\n");

          break;
        case 4:
          System.out.println("-------> A random question with power <-------");
          QuestionPower qp1 = new QuestionPower();
          qp1.generate();
          System.out.println(qp1);
          double res1p = qp1.solve();
          System.out.println("Result1: " + res1p);
          System.out.println(
              "---------------------------------------------------------------------\n");
          /*
          System.out.println("\n-------> A calculation with a given length <-------");
          sc = new Scanner(System.in);
          System.out.print("Length? ");
          int l = sc.nextInt();
          QuestionCalculation qc2 = new QuestionCalculation();
          qc2.generate(l);
          System.out.println(qc2);
          double res2 = qc2.solve();
          System.out.println("Result2: " + res2);
          System.out.println("---------------------------------------------------------------------\n");

          System.out.println("\n-------> A calculation with selected operators <-------");
          sc = new Scanner(System.in);
          char op = '+';
          ArrayList<Character> operators = new ArrayList<Character>();
          while (op != '0') {
              System.out.print("Operator? ");
              op = sc.next().charAt(0);
              if (op != '0') {
                  operators.add(op);
              }
          }
          QuestionCalculation qc3 = new QuestionCalculation();
          qc3.generate(operators);
          System.out.println(qc3);
          double res3 = qc3.solve();
          System.out.println("Result3: " + res3);
          System.out.println("---------------------------------------------------------------------\n");

          System.out.println("\n-------> A calculation with selected operators and given length <-------");
          sc = new Scanner(System.in);
          System.out.print("Length? ");
          int l2 = sc.nextInt();
          char op2 = '+';
          ArrayList<Character> operators2 = new ArrayList<Character>();
          while (op2 != '0') {
              System.out.print("Operator? ");
              op2 = sc.next().charAt(0);
              if (op2 != '0') {
                  operators2.add(op2);
              }
          }
          QuestionCalculation qc4 = new QuestionCalculation();
          qc4.generate(operators2, l2);
          System.out.println(qc4);
          double res4 = qc4.solve();
          System.out.println("Result4: " + res4);
          System.out.println("---------------------------------------------------------------------\n");

          System.out.println("\n-------> An exercise with these questions <-------");
          Exercise ex1 = new Exercise("calculation");
          ex1.setWording(new Wording());
          ex1.addQuestion(qc1);
          ex1.addQuestion(qc2);
          ex1.addQuestion(qc3);
          ex1.addQuestion(qc4);
          System.out.println(ex1);
          System.out.println("---------------------------------------------------------------------\n");

          System.out.println("\n-------> An exercise with a given type <-------");
          System.out.println("Type? ");
          String t = sc.next();
          System.out.println("");
          Exercise ex2 = new Exercise(t);
          ex2.generate();
          System.out.println(ex2);
          System.out.println("---------------------------------------------------------------------\n");*/

          break;
        case 5:
          System.out.println("\n-------> An exercise with a given type <-------");
          System.out.println("Type? ");
          String t3 = sc.next();
          System.out.println("Title ");
          String t4 = sc.next();
          System.out.println("");
          Exercise ex5 = new Exercise(t3);
          ex5.setTitle(t4);
          ex5.setWording(new Wording());
          ex5.generate();
          // System.out.println(ex5);
          System.out.println(
              "---------------------------------------------------------------------\n");
          System.out.println("Saving...");
          ex5.save();
          System.out.println("Loading...");
          Exercise ex5load = new Exercise();
          ex5load.load("ex-1.bmg");
          System.out.println(ex5);

          break;
        case 6:
          System.out.println("\n-------> Practice an exercise with a given type <-------");
          System.out.println("Type? ");
          String tp = sc.next();
          System.out.println("");
          Exercise ex1p = new Exercise(tp);
          ArrayList<Character> c = new ArrayList<Character>();
          c.add('+');
          c.add('-');
          ex1p.generate(c);
          Practice p1 = new Practice(ex1p);
          ex1p.practiceCalculation(p1);
          System.out.println(
              "---------------------------------------------------------------------\n");

          break;
        default:
          break;
      }
      ;
    }
  }