Skip to content

Не бейте сильно пишу первый раз в жизни :(#1

Open
nim0y wants to merge 3 commits intomainfrom
dev
Open

Не бейте сильно пишу первый раз в жизни :(#1
nim0y wants to merge 3 commits intomainfrom
dev

Conversation

@nim0y
Copy link
Copy Markdown
Owner

@nim0y nim0y commented Apr 18, 2023

4 дня ужаса
безнадеги
5-6 удалений всего и вся
и этот "монстр франкенштейна" ~ "готов".
Сдаюсь.
С богом.)))
Забыл в FormRub сделать 2ой метод на склонение слова Рубль.


public void finCountDown(int guestNumber) {
System.out.println("Добавлено:\n" + productNameC);
/*System.out.println(String.format(productNameC,System.lineSeparator()));*///хз нашел в интернетах,не разобрался
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Если есть вопросы - всегда можно спросить у куратора.
Но комментарии лучше не пушить

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Это для себя было , на случай если где то поломается.Спасибо!

if ((int)(Calc.finalCost % 100 / 10) == 1){
return " рублей.";
}
switch ((int) (Calc.finalCost % 10)){
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Совет на будущее: Если поставить курсор на switch, то можно увидеть фонарик желтый. Он подскажет улучшения кода

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Тут два момента :

  1. Хотелось\показалось что Swich тут подходит.
  2. при изменении выдает ошибки которые я не совсем понимаю как править.
    изображение_2023-04-19_080705750





Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Слишком много пустых строк, лучше не стоит так делать

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Принято убираю , в будущем постараюсь не оставлять.

@@ -0,0 +1,30 @@
import java.util.Scanner;

public class Gests {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Если предполагалось, что название класса переводится как "Гость", то тут опечатка

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Да нет , я пока писал неслолько раз создавал похожие классы.
Крутил разные куски кода , в итоге что бы не путаться в блокноте получилось так.
Понимаю, буду внимательнее.


public class Gests {
public static int guestNumber;
public static int Gest() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

И тут опечатка (см коммент выше)


public class Gests {
public static int guestNumber;
public static int Gest() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Зачем делать возвращаемый тип у метода int, если ты его не используешь? Для таких целей есть void
image





Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Тут тоже многовато строк

@@ -0,0 +1,24 @@
public class Calc {
String productNameC = "";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Названия productName вполне достаточно для понимания зачем оно нужно

case 4:
return " рубля.";
default:
return " рублей.";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Критическое замечание
Неверно выводится окончание слова рубль
image

nim0y added 2 commits April 19, 2023 08:33
… "лампочки" (больше желтым не подсвечивает).

Незнаю можно ли делать commit после отправки ссылки на Практикум. Риск дело благородное.))
}
if ((int) (Calc.finalCost % 10) == 1) {
return " рубль.";
} else if ((int) (Calc.finalCost % 10) == 2 || (int) (Calc.finalCost % 10) == 3 || (int) (Calc.finalCost % 10) == 4) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Как совет, ты можешь парой строчек выше завести переменную типа
int lastDigit = (int) (Calc.finalCost % 10) и ее подставлять во все проверки твоих условий, а то сейчас получается, что ты считаешь одно и то же 4 раза.
Это называется boilerplate code (код, который повторяется в нескольких местах). Очень легко так ошибиться

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