Skip to content

Calculator Console App - #45

Closed
ivangar wants to merge 10 commits into
the-csharp-academy:mainfrom
ivangar:main
Closed

ivangar wants to merge 10 commits into
the-csharp-academy:mainfrom
ivangar:main

Conversation

@ivangar

@ivangar ivangar commented Sep 28, 2026

Copy link
Copy Markdown

Summary
• Add a simple console calculator application implemented as a small library.
• Implements basic arithmetic, square root, exponentiation and trigonometric operations.
• Logs operations to a JSON file and keeps an in-memory history (printable / clearable).

Library: CalculatorLibrary
• CalculatorLibrary — core engine that orchestrates operations, logging and repository.
• CalculatorMath — math helpers with safe Try-style methods for divide, sqrt, exponent and trig (with validation + rounding).
• OperationFactory — factory for creating operation model instances.
• OperationRepository — in-memory repository for operation history with printing and clearing.
• CalculatorLogWriter — JSON logging to calculator.json with write/delete semantics.

How to run / test
• Open solution in Visual Studio 2026 or run from terminal:
• Set startup project to Calculator.ivangar.
• Run the project (F5 or dotnet run from project folder).
• Exercise menu options:
• Perform operations and verify console output.
• Check calculator.json created at app working directory and verify recorded operations.
• Use "View operations" to print history; "Delete operations" to clear history and reset JSON operations array.

@github-actions

Copy link
Copy Markdown

🚀 Project Submitted!

Thanks for submitting your project! I will review it soon.

📋 Please check the dashboard to make sure the project is marked as Pending.

⚠️ If it's not marked as pending, submit it manually using the URL for this PR.

@TheCSharpAcademy

Copy link
Copy Markdown

@ivangar Project approved! 😄✅ And well done for extending the project and completing the challenges! That's how you learn! It's always a good use of your time. 💪💪😟

🥋You still need to submit your Freecodecamp certificate before you start earning belts 😊

Feedback
🔍It would be great if users could use their previous results in new calculations!

🔍For further refinement, I'd keep the class library independent from the UI. CalculatorMath and OperationRepository write directly to Console. Ideally, the library should return results/errors and let the console project decide how to display them. This makes CalculatorLibrary reusable with other interfaces later.

🔍Reduce repetition in Application. BaseMathOperation, SquareRootOperation, PowerOperation, and TrigonometryOperation repeat very similar try/catch and double.IsNaN handling. Consider extracting the common execution/error-handling logic into a helper method to keep things DRY.

🔍Improve naming/convention consistency. Fields such as EndApp and Calculator are private fields but use PascalCase, while _random correctly uses the conventional underscore/camelCase style. Using _endApp and _calculator would make the code more consistent with standard C# conventions.

🗺️ I noticed that the only course you've completed so are the Introduction to Object-Oriented Programming and Intro to Web APIs. I'd highly recommend taking our LINQ Fundamentals course next. LINQ is one of the most important tools in modern C# and becoming comfortable with it will make your code much cleaner and more expressive.

☕If you like our roadmap, please consider buying us a coffee. We appreciate your help 🙂

Overall good work!✋🏻Looking forward to seeing your next projects!

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