Skip to content

HW - #66

Open
yaAppolitta wants to merge 12 commits into
Yandex-Practicum:masterfrom
yaAppolitta:master
Open

HW#66
yaAppolitta wants to merge 12 commits into
Yandex-Practicum:masterfrom
yaAppolitta:master

Conversation

@yaAppolitta

@yaAppolitta yaAppolitta commented Oct 4, 2022 •

Copy link
Copy Markdown

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

Comment thread src/main/java/Main.java
visitor = scanner.nextInt();
if (visitor <=1) {
System.out.println("Некорректное кол-во гостей");
System.out.println("Введите колличество гостей");

@MagicUnderHood MagicUnderHood Oct 5, 2022 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/Main.java

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/Main.java
boolean enough = true;

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/Main.java
menu_list.getListPrice(list.price);
System.out.println("Хотите ввести ещё товар?");
System.out.println("Eсли вы хотите ввести ещё товар, введите ДА");
System.out.println("Eсли вы хотите ввести ещё товар, введите Завершить ");

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
}
}

if (!enough){

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 можно убрать, и переменную enough тоже. Из цикла while может быть выход, только если пользователь введет Завершить, и тогда должен будет выполниться код здесь

Comment thread src/main/java/Main.java

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/Main.java
String receipt = "";
double pay = 0;

public void getAddList (String name, 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.

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

Comment thread src/main/java/Main.java
}
}

public static class Product {

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
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
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants