Skip to content

Практическая работа №1#1

Open
Venser724 wants to merge 7 commits intomainfrom
dev
Open

Практическая работа №1#1
Venser724 wants to merge 7 commits intomainfrom
dev

Conversation

@Venser724
Copy link
Copy Markdown
Owner

No description provided.

@@ -0,0 +1,29 @@
import java.util.ArrayList;

public class Formatter {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Здорово, что форматтер вынесен в отдельный класс!

Comment on lines +5 to +7
private final static String GREET = "На сколько человек требуется разделить счёт?";
private final static String ERRORINCORRECTNUMBER = "Введено некорректное число. \nВведите корректное число.";
private final static String ADDNEWGOOD = "Добавление товара. Ведите наименование товара или 'Завершить' для перехода к расчёту чека";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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



System.out.println(ADDNEWGOOD);
String name = scanner.nextLine();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Здесь есть небольшое повторение. Мы выводим строку перед циклом и в конце цикла. Можно использовать цикл do-while, чтобы этого избежать(Но это совсем не обязательно!).

return true;
}

static int inputNumber(Scanner scanner) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Мне нравится, что логика вынесена в отдельные функции, но кажется, что можно было сделать проще используюя стандартные методы сканера.

Comment on lines +43 to +44
if (!Character.isDigit(string.charAt(i))) {
if (!Character.isDigit(string.charAt(i))) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Зачем тут два раза одинаковая проверка?

System.out.println(GREET);
int number = 1;
Scanner scanner = new Scanner(System.in);
//int number = inputNumber(scanner);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Не очень хорошо коммитить закоментированный код

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants