Skip to content

Business Logic Example: Calculator

In this sample project, you will learn how to create a calculator as Business Logic. The calculator is responsible for the four basic arithmetic consisting of the mathematical operations addition, subtraction, multiplication and division. The Business Logic runs autonomously and does not need access to a business system.

This sample project can be downloaded for offline use:
  • `Download the full source code as Eclipse project (zipped file, ~2 MB) [Download]
  • `Download the binary code installable as Business Logic (zipped file, ~1,5 MB) [Download]

Package Structure and Classes

The classes are located in the src folder. The interface between Business Bot Platform and calculator is defined in class PluginClient in package de.citunius.businesslogic.plugin. The calculator's logic is located in class CalculatorBot.java.

An incoming message from the mobile user (for example, in the form of a calculation task) is registered by method handleIncomingMessage(). The method messageOnMenuPreferences() for the preference menu or method messageOnCommandCalculator() is invoked, depending on the latest stored UserState. The calculation task is now passed to a separate method and the result is returned to the user via the PluginReturnMessage object.

Testing the Calculator on the Platform

You need a valid account on the Business Bot Platform to test the calculator Business Logic. Therefore, go to http://www.citunius.de/ to register a new account. If you already have a valid account, follow the instructions for Adding a business bot as a local file in section Administration.