Skip to content

Проектная работа 1. - #1

Open
akularus05 wants to merge 1 commit into
mainfrom
dev
Open

akularus05 wants to merge 1 commit into
mainfrom
dev

Conversation

@akularus05

Copy link
Copy Markdown
Owner

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

double totalPrice=0;
String totalProduct = "" ;

public void priceEntry() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

else {
System.out.println("вы выбрали "+ nameOfProduct);
totalProduct = totalProduct +"\n"+ nameOfProduct;
priceEntry();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/Person.java

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

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 (valueOfPeople <= 0 || valueOfPeople > 20000) {...}

Comment thread src/main/java/Main.java
System.out.println("Hello world!");
Person person = new Person();
Calculator calculator = new Calculator();
person.numberOfPerson();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  • enterNumberOfPersons()
  • enterProducts()

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