Skip to content

console calculator is done - #1

Open
dashanutikova wants to merge 2 commits into
mainfrom
dev
Open

dashanutikova wants to merge 2 commits into
mainfrom
dev

Conversation

@dashanutikova

Copy link
Copy Markdown
Owner

Create calculator console app

Comment thread src/main/java/Calculator.java Outdated
Comment thread src/main/java/Calculator.java Outdated
public class Calculator {
Scanner scanner = new Scanner(System.in);

public void addCostToTheOrder(ArrayList<Position> listOfOrder, String positionName) {

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 way будет хранить список заказов внутри класса калькулятора.

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.

тут не поняла немного. Ты имеешь в виду создавать listOfOrders в Calculator и вообще всю логику работы с ним осуществлять только в классе Calculator?

@kekulta kekulta May 16, 2024 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Да, таким образом ты можешь инкапсулировать всю логику работу и оставить только несколько методов например: addOrder(name, cost), getTotalCost(), getCostByPerson(personsCount).

Comment thread src/main/java/Main.java Outdated
Comment thread src/main/java/Main.java Outdated
@@ -0,0 +1,26 @@
public class RubleFormatter {

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.

спасибо ;)

Comment thread src/main/java/RubleFormatter.java Outdated
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