Skip to content

Практическая работа 1 - #134

Closed
EkimovaDaria2004 wants to merge 2 commits into
Yandex-Practicum:masterfrom
EkimovaDaria2004:master
Closed

EkimovaDaria2004 wants to merge 2 commits into
Yandex-Practicum:masterfrom
EkimovaDaria2004:master

Conversation

@EkimovaDaria2004

Copy link
Copy Markdown

No description provided.

Comment thread src/main/java/Main.java
System.out.println("Привет Мир");
Scanner scanner = new Scanner(System.in);
int people = addPerson(scanner);
Calculator calculator = new Calculator();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Так как на протяжении жизни программы у нас используется один экземпляр класса Calculator, можно сделать его метод productsLists() static, чтобы не приходилось создавать единственный экземпляр калькулятора и напрямую вызывать метод Calculator.productsLists(scanner);

@@ -0,0 +1,26 @@
import java.util.Scanner;
public class Calculator {
public void productsLists( Scanner 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 принята конвенция, по которой методы нучше называть глаголами. Например, можно было было назвать createProductsList или как-то так.

productsLists(scanner);
case "Завершить":
System.out.println(answer);
System.out.println("Общая сумма"+sum);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Такие подряд идущие println лучше объединять в один, делая перенос строки при помощи \n. Некритично, но для небольшой экономии производительности один вызов лучше, чем два

@faritowich

Copy link
Copy Markdown

Также два момента, которые я забыл упомянуть в комментарии к заданию.

  1. Вы прислали ссылку на сам репозиторий https://github.com/EkimovaDaria2004/Java-Module-Project.git, но надо присылать ссылку на pull request, в котором я сейчас это пишу: Практическая работа 1 #134.
  2. Сейчас PR создан между веткой EkimovaDaria2004:master и Yandex-Practicum:master - по умолчанию GitHub предлагает создать Pull Request между вашим репозиторием и репозиторием Yandex-Practicum. Но нужно создать Pull Request между двумя ветками вашего репозитория.

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.

4 participants