Калькулятор 1.0 от безумного програмиста#18
Closed
ViktorVektor92 wants to merge 1 commit intoYandex-Practicum:devfrom
Closed
Калькулятор 1.0 от безумного програмиста#18ViktorVektor92 wants to merge 1 commit intoYandex-Practicum:devfrom
ViktorVektor92 wants to merge 1 commit intoYandex-Practicum:devfrom
Conversation
Takexito
reviewed
Jan 14, 2023
|
|
||
| System.out.println("Заполняем список заказанных товаров. После ввода всех товаров наберите 'Завершить'"); | ||
| Scanner sc = new Scanner(System.in); | ||
| String a = ""; //сюда записываются товары |
There was a problem hiding this comment.
Лучше давать более осмысленные имена переменным
Comment on lines
+23
to
+36
| while (true) { | ||
| sc = new Scanner(System.in); | ||
| if (sc.hasNextFloat()) { | ||
| b = sc.nextFloat(); | ||
| sc.nextLine(); | ||
| if (b < 0) { | ||
| System.out.println("Цена не может быть отрицательной. Введите корректную цену."); | ||
| } else { | ||
| break; | ||
| } | ||
| } else { | ||
| System.out.println("Введите цену в целочисленном виде."); | ||
| } | ||
| } |
There was a problem hiding this comment.
Это можно вынести в отдельную функцию
Comment on lines
+44
to
+63
| String ruble = ""; | ||
| int e = ((int) (pricePersonal)) % 10; //сюда записываем последнюю цифру | ||
| int f = (int) ((pricePersonal / 10) % 10); //здесь записываем предпоследнюю цифру | ||
| if (f == 1) { | ||
| ruble = "рублей"; | ||
| } else { | ||
| switch (e) { | ||
| case (1): | ||
| ruble = "рубль"; | ||
| break; | ||
| case (2): | ||
| case (3): | ||
| case (4): | ||
| ruble = "рубля"; | ||
| break; | ||
| default: | ||
| ruble = "рублей"; | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
это тоже можно было вынести в отдельную функцию и тогда бы код было читать проще
| import java.util.Scanner; | ||
|
|
||
| public class Counter { | ||
| public static int count() { |
There was a problem hiding this comment.
можно убрать ключевое слово static и тогда этот метод можно было бы вызвать в функции main предварительно создав экземпляр класса Counter counter = Counter()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.