Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Консольное приложение 1#1

Open
AndyRvlt wants to merge 3 commits intomain from
dev
Open

Консольное приложение 1 #1
AndyRvlt wants to merge 3 commits intomain from
dev

Conversation

@AndyRvlt
Copy link
Owner

@AndyRvlt AndyRvlt commented Feb 12, 2023

No description provided.

Comment on lines 18 to 30
if (Math.floor(endResalts) == 1) {
String endResaltsformat = String.format("%.2f", endResalts);
System.out.println("Итог: " + endResaltsformat + "рубль");

}
else if (Math.floor(endResalts) == 2||Math.floor(endResalts)==3||Math.floor(endResalts) ==4) {
String endResaltsformat = String.format("%.2f", endResalts);
System.out.println("Итог: " + endResaltsformat + "рубля");
}
else if(endResalts >= 5) {
String endResaltsformat = String.format("%.2f", endResalts);
System.out.println("Итог: " + endResaltsformat + " рублей");
}
Copy link

Choose a reason for hiding this comment

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

можно заменить с помощью конструкции switch case, для улучшения читаемости кода

AndyRvlt reacted with thumbs up emoji


// dev branch for Y.Practicum
public class Main {
Copy link

Choose a reason for hiding this comment

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

Много лишних пустых строк, стоит придерживаться порядка в файлах и код стайла

AndyRvlt reacted with thumbs up emoji

endResalts = menu.allPrice / person.allpersons;

if (Math.floor(endResalts) == 1) {
Copy link

Choose a reason for hiding this comment

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

не корректная логика, необходимо проверять последние цифры у чисел, а в твоем случае функция Math.floor() вернет просто целое число, без знаков после запятой. Например Math.floor(51,23) вернет 51 и окончание будет "рублей", а должно быть "рубль"

AndyRvlt reacted with thumbs up emoji
@@ -0,0 +1,46 @@
import java.util.Scanner;

class Menu {
Copy link

Choose a reason for hiding this comment

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

стоит поправить форматирование, в частности отступы для этого можно использовать хоткей ctrl+alt+L

AndyRvlt reacted with thumbs up emoji
break;
}
System.out.println("Введите стоимость товара в формате 00,00");
double priceProduct = scan.nextDouble();
Copy link

Choose a reason for hiding this comment

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

В данном случае приложение упадет, если пользователь введет не число. Можно исправить с помощью конструкции try catch, либо с помощью проверки scan.hasNextDouble()

AndyRvlt reacted with thumbs up emoji


System.out.println("Товар добавлен в счет. \nТовар: " + product + " Цена: " + priceProduct + "\nЕсли вы хотите продолжить выбор, то введите название товара \nЕсли выхотите завершить выбор товара, то введите команду \"Завершить\"");
allProduct=allProduct + product+"\n";
Copy link

Choose a reason for hiding this comment

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

можно использовать укороченную запись allproduct += product + "\n"

AndyRvlt reacted with thumbs up emoji
double priceProduct = scan.nextDouble();
if (priceProduct<0 ){
System.out.println("Не коректно введена стоимость товара. \nВведите стоимость товара в формате 00,00");
priceProduct = scan.nextDouble();
Copy link

Choose a reason for hiding this comment

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

в данном случае, пользователь может снова ввести число меньше нуля и программа его примет

AndyRvlt reacted with thumbs up emoji

System.out.println("На скольких человек необходимо разделить счёт");
while (true) {
int allperson = scanner.nextInt();
Copy link

Choose a reason for hiding this comment

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

приложение упадет, если будет не число

AndyRvlt reacted with thumbs up emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@Takexito Takexito Takexito left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /