# Section 8.11.3.1:
ANSWERS

###### class ANSWERS < $BINARY

#### Formal Types

types
SAME = ANSWERS ;

This class implements the concept of a logical response by a user (which is expected to be in the form of a text string) to a question requiring a yes/no answer.

The corresponding names in the culture-dependent resources file should be the language-dependent names for the English notions 'No' and 'Yes'.

#### External specifications

The following features are required to be implemented for this class in accordance with the specifications given in $BINARY :-

- create(storage : BINSTR) : SAME
- build(cursor : BIN_CURSOR) : SAME
- read(cursor : BIN_CURSOR) : SAME
- binstr : BINSTR
- write(fyle : BIN_FILE)

#### create

This feature produces a new recognizer for potential answers given the affirmative and negative extended regular expressions as arguments. These regular expressions are provided for in the international culture spcification document (ISO/IEC 14652).

create | (
| yes : REG_EXP,
| no : REG_EXP
| ) : SAME

##### Formal Signature

create(yes : REG_EXP, no : REG_EXP) res : SAME

##### Pre-condition

pre yes <> no

##### Post-condition

The result, not being an optional object is the newly created recognizer and the post-condition is true.

This creation creates a recognizer for yes/no answers from the extended regular expression arguments.

#### yes

This feature returns true provided that the string is a valid match for the 'yes' regular expression known to the recognizer, otherwise false. It must, however, be pointed out that returning false does not mean that the string was recognized as being negative - merely that it was not recognised as being affirmative.

yes | (
| val : STR
| ) : BOOL

##### Formal Signature

yes(self : SAME, val : STR) res : BOOL

##### Pre-condition

pre STR.size(val) > 0

##### Post-condition

post res = (response(self,val) = TRI_STATE.yes)

This predicate returns true if and only if the argument is a match for the affirmative regular expression known to the recognizer.

#### no

This feature returns true provided that the string is a valid match for the 'no' regular expression known to the recognizer, otherwise false. It must, however, be pointed out that returning false does not mean that the string was recognized as being affirmative - merely that it was not recognised as being negative.

no | (
| val : STR
| ) : BOOL

##### Formal Signature

no(self : SAME, val : STR) res : BOOL

##### Pre-condition

pre STR.size(val) > 0

##### Post-condition

post res = (response(self,val) = TRI_STATE.no)

This predicate returns true if and only if the argument is a match for the negaative regular expression known to the recognizer.

#### response

This feature provides the response value explicitly, rather than as a truth value used in the previous two features.

response | (
| val : STR
| ) : TRI_STATE

##### Formal Signature

response(self : SAME, val : STR) res : TRI_STATE

##### Pre-condition

pre STR.size(val) > 0

##### Post-condition

post res in set dom TRI_STATE

This feature provides the three state logic value which represents the result of attempts at matching val against both affirmative and negative regular expressions as known to this recognizer.

| Language Index |  | Library Index |  | Non-numeric Index

Comments or enquiries should be made to Keith Hopper. Page last modified: Wednesday, 22 November 2000. |