Skip to content

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

Open
brtna8 wants to merge 6 commits into
mainfrom
dev
Open

brtna8 wants to merge 6 commits into
mainfrom
dev

Conversation

@brtna8

@brtna8 brtna8 commented Jan 28, 2024

Copy link
Copy Markdown
Owner

👍

Comment thread src/main/java/Main.java
TradingCalculator tradingCalculator = new TradingCalculator(amountOfPeople);
tradingCalculator.calculateAndDisp();
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

По хорошему надо выносить всю эту логику из класса Main. Этот класс обычно призван только стартануть программу, а все остальное должно быть сделано в специальных классах.

Comment thread src/main/java/Main.java Outdated
return rubles + " " + rublesText + " " + kopecks + " " + kopecksText;
}
} No newline at end of file
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Отдельные классы лучше держать с отдельных файлах - это улучшает читаемость

Comment thread src/main/java/Main.java

class TradingCalculator {
private double totalCost = 0.0; // итоговая стоимость
private int amountOfPeople; // количество человек

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

final

Comment thread src/main/java/Main.java
class TradingCalculator {
private double totalCost = 0.0; // итоговая стоимость
private int amountOfPeople; // количество человек
private List<String> productsList = new ArrayList<>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

final

Comment thread src/main/java/Main.java Outdated
int kopecks = (int) ((amount - rubles) * 100);

String rublesText = "";
String kopecksText = "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

В данном случае нет необходимости присваивать начальные значение при объявлении

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