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

HW#66

Open
yaAppolitta wants to merge 12 commits intoYandex-Practicum:master from
yaAppolitta:master
Open

HW #66
yaAppolitta wants to merge 12 commits intoYandex-Practicum:master from
yaAppolitta:master

Conversation

@yaAppolitta
Copy link

@yaAppolitta yaAppolitta commented Oct 4, 2022
edited
Loading

Спринт 2. Проектная работа 1.
попытка 2

s-buvaka and others added 12 commits July 27, 2022 22:57
visitor = scanner.nextInt();
if (visitor <=1) {
System.out.println("Некорректное кол-во гостей");
System.out.println("Введите колличество гостей");
Copy link

@MagicUnderHood MagicUnderHood Oct 5, 2022
edited
Loading

Choose a reason for hiding this comment

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

Можно перенести эту строчку наверх, сразу после while, тогда отсюда и перед while её можно удалить


Product list = new Product();
Calculate menu_list = new Calculate();
while (enough) {
Copy link

@MagicUnderHood MagicUnderHood Oct 5, 2022

Choose a reason for hiding this comment

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

Можно просто прописать while(true)

boolean enough = true;

Product list = new Product();
Calculate menu_list = new Calculate();
Copy link

@MagicUnderHood MagicUnderHood Oct 5, 2022

Choose a reason for hiding this comment

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

Для именования переменных лучше использовать верблюжий регистр, то есть menuList

menu_list.getListPrice(list.price);
System.out.println("Хотите ввести ещё товар?");
System.out.println("Eсли вы хотите ввести ещё товар, введите ДА");
System.out.println("Eсли вы хотите ввести ещё товар, введите Завершить ");
Copy link

@MagicUnderHood MagicUnderHood Oct 5, 2022

Choose a reason for hiding this comment

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

Наверное, тут должно быть "Если вы не хотите больше вводить товары, введите Завершить"

}
}

if (!enough){
Copy link

@MagicUnderHood MagicUnderHood Oct 5, 2022

Choose a reason for hiding this comment

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

Этот if можно убрать, и переменную enough тоже. Из цикла while может быть выход, только если пользователь введет Завершить, и тогда должен будет выполниться код здесь


if ((rub == 0 ) || (rub == 5) || (rub == 6) || (rub == 7 ) || (rub == 8 ) || (rub == 9)){
rubString = "рублей";
} else if ((rub == 2) || (rub == 4) || (rub == 3) ){
Copy link

@MagicUnderHood MagicUnderHood Oct 5, 2022

Choose a reason for hiding this comment

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

Можно упростить - rub >= 2 && rub <= 4

String receipt = "";
double pay = 0;

public void getAddList (String name, double price) {
Copy link

@MagicUnderHood MagicUnderHood Oct 5, 2022

Choose a reason for hiding this comment

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

Этот и getListPrice методы называются "get", то есть "получить", но ничего не возвращают. Лучше назвать "addProduct" и "addPrice". Ещё можно передавать в параметре этого метода сразу объект класса Product, и из него брать имя и цену

}
}

public static class Product {
Copy link

@MagicUnderHood MagicUnderHood Oct 5, 2022

Choose a reason for hiding this comment

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

Классы лучше в отдельный файл располагать, и тогда не надо будет делать их статическими

String rubString = "";
int rub = (int) (pay % 10);
int rubTeen = (int) (pay % 100);
if ((rub == 0 ) || (rub == 5) || (rub == 6) || (rub == 7 ) || (rub == 8 ) || (rub == 9 ) || ((rubTeen >= 11) && (rubTeen <= 14))){
Copy link

@MagicUnderHood MagicUnderHood Oct 6, 2022

Choose a reason for hiding this comment

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

Можно упростить условие - rub == 0 || (rub >= 5 && rub <= 9) || (rubTeen >= 11 && rubTeen <= 14)

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

Reviewers

1 more reviewer

@MagicUnderHood MagicUnderHood MagicUnderHood 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 によって変換されたページ (->オリジナル) /