Skip to content

my first project - #1

Open
baha-kenpachi wants to merge 8 commits into
mainfrom
dev
Open

baha-kenpachi wants to merge 8 commits into
mainfrom
dev

Conversation

@baha-kenpachi

Copy link
Copy Markdown
Owner

for code reviewing

Comment thread src/main/java/Main.java Outdated
System.out.println("Не корректное колличество людей, значение должно быть больше 1.");
} else { //начинаем собирать название товаров и цены пока не будет команды завершить
Calculate.calculate(quantityPeople); // quantityPeople добавляем что бы сумму разделить на количество людей
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Лучше вынести функционал для ввода количества людей и обработки ввода в отдельную сущность (метод, класс), и затем вызывать их там, где необходимо. Так же, как это сделано с Calculate и Formater. Это позволяет улучшить читаемость кода, т.к. отдельные функциональные блоки расположены отдельно друг от друга и не смешиваются.

Comment thread src/main/java/Formater.java Outdated
@@ -0,0 +1,13 @@
public class Formater {
public static String formater(double formaterring) { // 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.

В Java принята конвенция, согласно которой методы принято называть глаголами camelCase'ом, см. https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
Так что лучше метод назвать format

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

System.out.println("Товар успешно добавлен");

System.out.println("Желаете добавить еще товар?");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Два таких подряд идущих println лучше объединить в один

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

System.out.println("Напишите цену на блюдо:");
double productCost = scanner.nextDouble();
sum = sum + productCost; // суммируем стоимость товаров

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно также сократить до sum += productCost;

Comment thread src/main/java/Formater.java Outdated
public class Formater {
public static String formater(double formaterring) { // formatter возвращет рубль в правильной форме
String rub;
if (Math.floor(formaterring) == 1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Math.floor(formaterring) используется в методе три раза, можно присвоить это значение переменной в начале метода как-то так:
int roundedNumber = Math.floor(formaterring);


}

public static void calculate2(int quantityPeople) { // без учета отрицательного ввода

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 thread src/main/java/Format.java
int preLastDigit = roundedNumber % 100 / 10;
if (preLastDigit == 1)
{
return "рублей";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if (preLastDigit == 1)
{

Не совсем джава-стиль. Вообще есть хороший хоткей, можно нажать Alt + Ctrl + L и студия красиво отформатирует весь код на экране

Comment thread src/main/java/Format.java
return "рубля";
default:
return "рублей";
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно этот switch превратить в более короткий и читабельный формат:

  return switch (roundedNumber % 10) {
           case 1 -> "рубль";
           case 2, 3, 4 -> "рубля";
           default -> "рублей";
       };

Comment thread src/main/java/People.java
//break;
} else if (quantityPeople < 1) { //просим заново ввести колличество людей
System.out.println("Не корректное колличество людей, значение должно быть больше 1.");
} else if (quantityPeople > 1) { //начинаем собирать название товаров и цены пока не будет команды завершить

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно просто else

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