Skip to content

First implementation of Pub Bill Calculator - #1

Open
Aleks-AGN wants to merge 2 commits into
mainfrom
dev
Open

Aleks-AGN wants to merge 2 commits into
mainfrom
dev

Conversation

@Aleks-AGN

Copy link
Copy Markdown
Owner

Первая реализация консольной программы "Калькулятор счета".

Приложение содержит следующие отдельные классы:

  • класс Main - основной класс;
  • класс InputCals, содержащий логику обработки ввода исходных значений;
  • класс Calculator, содержащий логику добавления и подсчёта товаров;
  • класс Product с полями "имя" — строка и "цена" — дробное значение;
  • класс OutputCals, содержащий логику обработки вывода результата расчета;
  • класс Formatter, содержащий метод получения слова рубль в правильном падеже и форматированного вывода дробного значения.

Comment thread src/main/java/Formatter.java Outdated
}
}

strBuilder.append(String.format("%.2f", price) + " " + currency);

@AleksandrIlinskii AleksandrIlinskii May 4, 2024 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

" " тоже лучше засунуть в append
image

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Исправлено

} else {
break;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Тут нет проверки на то, что в названии товара ничего не написано

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

image

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Добавлена проверка

Comment thread src/main/java/InputCalc.java Outdated

while (true) {
System.out.println("Введите стоимость товара в формате 'рубли.копейки':");
scanner.useLocale(Locale.US);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Этой строкой ты ограничиваешь запятую в качестве разделителя
image

Copy link
Copy Markdown
Owner Author

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