Answer the question
In order to leave comments, you need to log in
What logical classes should a simple calculator be divided into from an OOP point of view?
Good day to all! Guys, please tell me what logical classes a primitive calculator ( +, - , * , /) can be divided into from the point of view of OOP, you need to complete a test task, I did it in one class - they asked to divide it. Thank you all very much)
Answer the question
In order to leave comments, you need to log in
You have only 4 actions, so you can make the App classes (it has a main method to launch the application and get a string from the console), a Parser class to “parse” the string into arguments and an operator (math.action), and the last Calculator class (takes arguments and mathematical operator), performs actions and displays the result.
Well, without knowing what you wrote there, you can’t say.
If there is a calculation of complex expressions, it is logical to select Tokenizer (splits the string into tokens) Parser (parses the expression presented as a list of tokens), Calculator (calculates the parsed syntactically correct expression, for example, using the Polish inverse notation).
If there is interactive (input / output to the console, windows), it makes sense to make MVP or MVC.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question