Solutions:
MyLine
which has a private string and
methods:
copyIn
to copy-in;
print
to print the string;
countChar
which takes as argument a
character and returns the number of
times that letter appears in the private string;
countChars
which takes as argument a string and returns the number of
times any letter in that string, called the match string, appears in
the private string;
translate
which takes two strings as
arguments, a match string
and a translation string, and replaces each occurrence of a character in
the match string by the corresponding character in the translation string.
The caller must make sure that the match and translation strings are the
same length, and a corresponding character between the match and translation
strings are characters which occur in the same position in each string;
isEmpty
which returns 1 if the private string is
empty, 0 else;
index
which takes a string argument s, the
match string, and an
integer argument mode
and scans the private string from
its beginning until:
prefix
which takes a string argument and
an integer i and copies into the string argument the first i characters
in the private string. It adds a null character to the end of the copy,
and it then removes the first i characters from the private string.
That is, the private string now starts at the i-th character.