Skip to content

The purpose of this Calculator is to practice unit testing in Go

License

Notifications You must be signed in to change notification settings

killerasus/GoCalc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go RPN Calculator

An over-engineered RPN calculator built to practice unit testing, error reporting, GUI development, and CLI in Go.

Build Status

CLI

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.

Using CLI for evaluating expressions

GUI

Fyne

A GUI version of the calculator made with the free and open source fyne toolkit.

Calculator GUI in Fyne

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.

Testing

Run tests with go test ./stack ./calculator ./operations -v command in the root directory.

Class Diagram

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
    }
Loading

About

The purpose of this Calculator is to practice unit testing in Go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages