An over-engineered RPN calculator built to practice unit testing, error reporting, GUI development, and CLI in Go.
To run the command line interface of the Go RPN Calculator, go to folder cli
and run go run cli.go
or go build
.
CLI interface supports flags. See implemented flags and usage with -h
or -help
.
For example: CLI supports expression evaluation. The result is stacked.
A GUI version of the calculator made with the free and open source fyne toolkit.
Compile with go build -o gorpn.exe gui/fyne/main.go
. Remember that you will have to provide a GNU C++ compiler (in Windows you can use MSYS2 to provide GCC).
Calculator icons created by Freepik - Flaticon.
Run tests with go test ./stack ./calculator ./operations -v
command in the root directory.
classDiagram
IStack <|-- Stack
Calculator *-- Stack
Calculator --> Operations
class IStack {
<<interface>>
+Push(float64)
+Pop() float64
+Peek() float64
+Peeki(int i) (float64, bool)
+Size() int
+IsEmpty() bool
}
class Stack {
-float64[]
}
class Calculator {
-Stack stack
+Size() int
+Push(float64 a) void
+Peek() (float64, bool)
+Peeki(i int) (float64, bool)
+Pop() (float64, bool)
+Add() (float64, bool)
+Subtract() (float64, bool)
+Multiplication() (float64, bool)
+Division() (float64, bool)
+Evaluate(string e) (v float64, ok bool)
}
class Operations {
<<namespace>>
+Add(float64 a, float64 b) float64
+Subtract(float64 a, float64 b) float64
+Multiply(float64 a, float64 b) float64
+Divide(float64 a, float64 b) float64
+UnaryNegative(float64 a) float64
+Root(float64 a, float64 root) float64
+SquareRoot(float64 a) float64
}