Skip to content

Sprint 2 Task - #1

Closed
niksshg wants to merge 4 commits into
mainfrom
master
Closed

niksshg wants to merge 4 commits into
mainfrom
master

Conversation

@niksshg

@niksshg niksshg commented Oct 25, 2022

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/main/java/Main.java Outdated
private static Scanner s = new Scanner(System.in);
private static int customers;
private static String product;
private static double price;

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/Main.java Outdated
customers = s.nextInt();
while (customers <= 1) {
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 в один, а перенос сделать при помощи \n

Comment thread src/main/java/Main.java Outdated
System.out.println("Введите корректное количество гостей. Если гостей меньше двух, то расчет не требуется");
customers = s.nextInt();
}
c = new Calculator(customers, 0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно сделать методы и поля Calculator static, чтобы не приходилось создавать экземпляр, а обращаться к его методам напрямую

Comment thread src/main/java/Main.java Outdated
} else if (enough.equalsIgnoreCase("да")){
break;
}
} while (!enough.equalsIgnoreCase("нет") || !enough.equalsIgnoreCase("да"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Это условие всегда true, enough всегда будет или не "нет", или не "да". В таком случае лучше использовать цикл while(true)

Comment thread src/main/java/Calculator.java Outdated
int friendsCount;
int numberOfCustomers;
double bill;
Product p;

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/Calculator.java Outdated
case 2:
case 3:
case 4:
corretFormat = value + " " + "рубля";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Есть принцип, который называется DRY - Don't repeat yourself. Можно вынести повторяющиеся
corretFormat = value + " " в отдельную строку, а в case обрабатывать и добавлять к ней рубли с окончаниями

@niksshg niksshg closed this Nov 10, 2022
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