Skip to content

Lab1#12

Open
parfen01 wants to merge 12 commits into
Rrenkens:mainfrom
parfen01:developing
Open

Lab1#12
parfen01 wants to merge 12 commits into
Rrenkens:mainfrom
parfen01:developing

Conversation

@parfen01
Copy link
Copy Markdown
Contributor

@parfen01 parfen01 commented Oct 8, 2022

Сделаны все обязательные пункты, кроме кастомных эксепшненов. Также сделан енам и нестед классы

Made all abstract classes + pullTaskGenerator + two specific tasks
Made all necessary classes and interfaces + some system exceptions
Created 5 Quisez and test system for them
All made tests are passed. All generators are nested in tasks.
@parfen01 parfen01 changed the title Developing Lab1 Oct 8, 2022
Copy link
Copy Markdown
Owner

@Rrenkens Rrenkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пока не очень хорошо, так как полностью не работает одна задача, и вторая не всегда. Пока что начни переделывать, на паре расскажу как это зачтется. С допами все хорошо.

Comment thread lab-01/src/Main.java
Map<String, Quiz> result = new TreeMap<>();
ExpressionTask.Generator firstTaskGenerator = new ExpressionTask.Generator(
1, 100, EnumSet.allOf(MathTask.Operation.class));
Quiz firstQuiz = new Quiz(firstTaskGenerator, 10);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все константы лучше выносить в отдельный файлик. Это касается про кол-во тестов и параметры генератора.

Comment thread lab-01/src/Main.java Outdated
TextTask thirdTextTask = new TextTask("Лектор расписался в журнале." +
" Там было 3 н-ки." +
" Сколько студентов было на паре?", "Один");
TextTask foursTextTask = new TextTask("what the fastest mammal in the world?", "Cheetah");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Помарка foursTextTask. В нескольких местах.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено

Comment thread lab-01/src/Main.java Outdated
secondTextTask,
thirdTextTask,
foursTextTask,
firstTextTask);
Copy link
Copy Markdown
Owner

@Rrenkens Rrenkens Nov 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кошмар перфикциониста.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено

Comment thread lab-01/src/by/parfen01/quiser/Quiz.java Outdated
public Quiz(Task.Generator generator, int taskCount) {
this.generator = generator;
this.taskCount = taskCount;
nextTask = generator.generate();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут лучше конструировать задания только по мере надобности в nextTask.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено


public ExpressionTask(int firstNumber, int secondNumber, Operation operation) {
super(firstNumber, secondNumber, operation);
text = firstNumber + Operation.toChar(operation) + String.valueOf(secondNumber) + "=?";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String.valueOf(firstNumber)
Без этого совсем не правильно генерируются задания.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У меня сразу оба String.valueOf() были, когда я тестировал. Потом IDE сказало, что второй можно убрать, а я случайно первый убрал

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено

answer = "invalid operation";
return;
}
answer = String.valueOf(calculate(firstNumber, secondNumber, operation));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calculate возвращает int, а ты никак не проверяешь, что деление будет целочисленным. Это касается и EquationTask.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переделал, чтобы всё с даблами работало

if (positionOfX == 0) {
text = "X" + Operation.toChar(operation) + firstNumber + "=" + secondNumber;
if (firstNumber == 0 && operation == Operation.DIVISION) {
answer = "invalid operation";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

На мой взгляд везде, в таких случаях, лучше было бы перегенерить (за это не снижал).

return generators.get(i).generate();
}
catch (Exception e) {
if (i == generators.size()) {
Copy link
Copy Markdown
Owner

@Rrenkens Rrenkens Nov 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут лучше было бы просто continue. Не совсем понятно зачем нам ошибка какого-то генератора.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено

*/
@Override
public Task generate() {
if (isAllowedDuplicate) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут мне не очень нравится, зачем хранить еще один set usedTextsOfTasks. Если нам нужны дубликаты просто сохраняем в массив, если нет убираем их, а потом просто делаем shuffle.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено

import java.util.EnumSet;

public class EquationTask extends AbstractMathTask {
int positionOfX;
Copy link
Copy Markdown
Owner

@Rrenkens Rrenkens Nov 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно добавить модификатор доступа и константность. В других файлах тоже посмотри на это внимательно.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Везде добавлено

}

default MathTask.Operation getRandomOperationFromSet() {
while (true) {
Copy link
Copy Markdown
Owner

@Rrenkens Rrenkens Nov 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Подумай как это сделать элегантнее.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделал

@Rrenkens Rrenkens added the question Further information is requested label Nov 24, 2022
@Rrenkens
Copy link
Copy Markdown
Owner

Rrenkens commented Nov 25, 2022

Ну пока что такая оценка:

  • -1 за ExpressionTask. Тут можно было протестировать!!!
  • -0.75 за генерацию вопросов с double.
  • -0.5 за все остальные мелочи.
  • -0.25 за не ленивость генерации задачи.

В итоге 7.5 . В остальном хорошая работа. +2 балла за допы.

@parfen01
Copy link
Copy Markdown
Contributor Author

Будет ещё один коммит минимум. Пока не перепроверять

@parfen01
Copy link
Copy Markdown
Contributor Author

parfen01 commented Nov 27, 2022

Исправил всё, кроме выноса констант. Также перевёл все вычисления в даблы и сделал доп на пресижен и пресижен в ответе. Можно перепроверять

@parfen01 parfen01 closed this Nov 29, 2022
@parfen01 parfen01 deleted the developing branch November 29, 2022 06:58
@parfen01 parfen01 restored the developing branch November 29, 2022 06:59
@parfen01 parfen01 reopened this Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants