Skip to content

Init commit - #1

Open
Joelz847 wants to merge 8 commits into
mainfrom
dev
Open

Joelz847 wants to merge 8 commits into
mainfrom
dev

Conversation

@Joelz847

Copy link
Copy Markdown
Owner

No description provided.

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



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.

  • Форматирование кода - в Java принят немного другой стиль форматирования кода. Если не вдаваться в детали, то легко и быстро отформатировать код в Android Studio можно следующей комбинацией клавиш: в Windows Ctrl + Alt + L , в MacOs ⌘ + ⌥ + L.

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


import java.util.Scanner;

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 принято делать так: один класс-один файл

Comment thread src/main/java/Main.java Outdated
return "ей";
} else {
switch (money) {
case 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.

рекомендую повторить синтаксис switch - case. Кажется, здесь необходимо использование break

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

}
if (members <=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.

здесь взаимоисключающие условия, оптимальнее использовать конструкцию if-else

Comment thread src/main/java/Main.java

Product productList = new 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.

Зачем выводит Hello world!?

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


if (members > 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.

тк members < 0 и members > 1 - взаимоисключающие условия, то их стоит реализовать через блок if - else if

Comment thread src/main/java/Main.java Outdated
productList.price = 0; //обязательная инициализация для компилятора


String tmp = scanner.nextLine(); // scanner.nextInt() нельзя выдаст ошибку, т.к. введён не int

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

При проверке значенийй удобно использовать методы scanner.hasNextInt()/hasNextFloat() или try-catch

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

productList.listName += input;

productList.listName = productList.listName + "=" + String.format("%.2f", productList.price) + "р.\n";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Рекомендация: строки лучше соединять через stringBuilder - это оптимальнее по использованию памяти

int money = (int) summ;


if (money % 100 >= 5 && money % 100 <= 20) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

money % 100 используется больше одного раза - стоит вынести в переменную

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.

3 participants