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

Open
KotlinPunk wants to merge 1 commit intomain from
dev
Open

Консольное приложение #1
KotlinPunk wants to merge 1 commit intomain from
dev

Conversation

@KotlinPunk
Copy link
Owner

@KotlinPunk KotlinPunk commented Mar 1, 2024

Проектная работа No1. Консольное приложение.


public class Calculator {

public static String calculator(int N) {
Copy link

@Charmandik Charmandik Mar 1, 2024

Choose a reason for hiding this comment

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

старайся избегать использования статических функций, так как они не очищаются и всегда занимают место в памяти

Copy link
Owner Author

@KotlinPunk KotlinPunk Mar 1, 2024

Choose a reason for hiding this comment

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

Понял. Но вроде в курсе ещё не встречал эту информацию)

System.out.println("Товар успешно добавлен");

System.out.println("Будут ли ещё товары? Если нет, пожалуйста, введите 'Завершить'.");
String z = scanner.next();
Copy link

@Charmandik Charmandik Mar 1, 2024

Choose a reason for hiding this comment

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

не сокращай имена переменных и не используй аббревиатуры, к коду приходится возвращаться время от времени и бывает сложно понять, что значит то или иное сокращение через месяц или два

KotlinPunk reacted with thumbs up emoji
}
public static String rub(double midSum) {
double v = Math.floor(midSum);
if (v % 100 >= 11 && v % 100 <=14) {
Copy link

@Charmandik Charmandik Mar 1, 2024

Choose a reason for hiding this comment

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

для ситуаций когда 2 и более условия, почти всегда лучше использовать switch/case

KotlinPunk reacted with thumbs up emoji

try {
numberOfPeople = scanner.nextInt();
} catch (InputMismatchException q) {
Copy link

@Charmandik Charmandik Mar 1, 2024

Choose a reason for hiding this comment

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

с одной стороны, когда ты используешь более конкретный класc ошибки, то ты как бы делаешь свой код более точным, но с другой стороны, если произойдет любая другая ошибка, то твой код упадет и всё сломается, поэтому если на это нет острой необходимости, то проще использовать просто класс Exception

Copy link
Owner Author

@KotlinPunk KotlinPunk Mar 1, 2024

Choose a reason for hiding this comment

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

Вот тут я просто глядел форумы. Искал ответ, как лучше будет. Поэтому решил оставить так. Но я вас понял. Спасибо.

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

Reviewers

1 more reviewer

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