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
akularus05 wants to merge 1 commit intomain from
dev
Open

Проектная работа 1. #1
akularus05 wants to merge 1 commit intomain from
dev

Conversation

@akularus05
Copy link
Owner

@akularus05 akularus05 commented May 2, 2023

Проектная работа номер 1 на проверку.

double totalPrice=0;
String totalProduct = "" ;

public void priceEntry() {
Copy link

@kirillNay kirillNay May 3, 2023

Choose a reason for hiding this comment

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

⏫ Так как функция priceEntry используется только внутри класса Calculator, мы можем сделать ее private

akularus05 reacted with thumbs up emoji
else {
System.out.println("вы выбрали "+ nameOfProduct);
totalProduct = totalProduct +"\n"+ nameOfProduct;
priceEntry();
Copy link

@kirillNay kirillNay May 3, 2023

Choose a reason for hiding this comment

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

⏫ Так как такая конкатенция строк будет создавать новый объект String каждый раз, можно воспользоваться более оптимизированным способом формирования строки - с помощью StringBuilder, и добавлять строку с помощью метода append

akularus05 reacted with thumbs up emoji

} else if (valueOfPeople <= 0 ) {
System.out.println("Введены некорректные данные, попробуйте еще раз");
scanner1.nextLine();
Copy link

@kirillNay kirillNay May 3, 2023

Choose a reason for hiding this comment

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

⏫ Эти два условия можно было бы объединить под

if (valueOfPeople <= 0 || valueOfPeople > 20000) {...}

akularus05 reacted with thumbs up emoji
System.out.println("Hello world!");
Person person = new Person();
Calculator calculator = new Calculator();
person.numberOfPerson();
Copy link

@kirillNay kirillNay May 3, 2023

Choose a reason for hiding this comment

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

⏫ Обычно функции, которые выполняют какое-либо действие принято называть глаголами. В твоем случае было бы удобнее назвать:

  • enterNumberOfPersons()
  • enterProducts()

akularus05 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

@kirillNay kirillNay kirillNay approved these changes

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