# Requirements

Basic requirement specification defining the calculator to be implemented and tested.

## Basic Requirements

For this tutorial we will consider a very small example case study. We assume that some company
wants to implement a calculator that computes the basic arithmetic operations
`+`, `-`, `*`, and
`/` for two integer values and stores the result of the operation in an
internal result-register. The two integer values are stored in internal registers.

During the first analysis and specifiation phases, the company will formulate a set of requirements to which the specification as well as the later implementation will have to adhere. These requirements will also be provided to the quality assurance team in order to prepare for testing the product, before the product will be produced and shipped.

Informally, the company will expect the product to do the right things. All operations shall be computed according to their mathematical meaning, i.e. e.g.:

- values are of integer domain
- values are either zero, positive, or negative
- adding a negative value to a positive value means subtraction
- '-' * '-' has to result in positive values,
- division by zero has to be treated as an error,
`a`-`a`= 0- e.t.c.

In order to specify the quality criteria for the product, they finally come up with a set of requirements.

Suppose that for building the calculator implementation, the following requirements have been formulated:

## Functional Requirements

- Addition
- Addition of two integer values shall result in an integer result, according to the rules of addition regarding signed integers.
- Subtraction
- Subtraction of two integer values shall result in an integer result, according to the rules of subtraction regarding signed integers. Subtraction shall always subtract the operand in register 2 from the operand in register 1.
- Multiplication
- Multiplication of two integer values shall result in an integer result, according to the rules of multiplication regarding signed integers.
- Division
- Division of two integer values shall result in an integer result, according to
the rules of division regarding signed integers. Division by zero shall be handled. Division will
always divide the first operand (in register 1) by the second operand (in register 2).
- Division by zero
- It is an unrecoverable error if operand register 2 is 0

- Reset
- A reset operation shall leave the unrecoverable error state and reenable the calculator for inputs.

## Non-functional Requirements

- Registers
- The calculator has three registers: two operand registers (1, 2) and a result register. All three registers are designed to keep integer values.
- Stability
- All input errors, i.e. illegal register-numbers and undefined operators must be handled by environment in which the implementation is instantiated. The calculator will only deal with 0-divisor.
- Operations domain
- The operations implemented by the calculator: addition, subtraction, multiplication and division without fractions (integer division) are integer operations, i.e. they shall accept signed integers as arguments and shall produce signed integers as results.
- Overflows
- Overflows, i.e. domain overruns, shall not be considered.
- Operation errors
- It shall be treated as an unrecoverable error (requires a calculator reset) if
operation is none of the values below when invoking computation
- 1 = +
- 2 = *
- 3 = -
- 4 = /

## Requirements in the Rhapsody project

The requirements are part of the specification model and can be found in the
tutorial model in package `RequirementsPkg`

`<<trace>>`dependency) and then anchor the requirement on the individual statechart element. In this tutorial the requirements are unreferenced in the model.