submit itec320-01 wordpkg.ads wordpkg-utilities.adb
wordpkg-palindromes.adb more_pals.adb
Last modified:
Updates:
You should now use this URL for the assignment checker: itec-noki01. The old one will disappear.
This assignment involves wordpkg
. Remember that a word is a contiguous sequence of
non-whitespace characters.
For this assignment there are several main parts:
wordpkg.ads
to make it generic, adding a maximum word size as a parameter. wordpkg.utilities
. This package will
contain routines that perform certain operations on a word
. wordpkg.palindromes
. This package will
contain a routine that enables checking the palindrome status (described below) of a word
. word
s). Since we are dealing with a package and two child-packages (each with a .ads
spec and .adb
body),
plus a driver:
this program will have a total of seven files.
Of the four provided files, only one should be modified:
wordpkg-utilities.adb
.wordpkg-palindromes.adb
.These child packages are, and must be, generic, and you should review how to instantiate a child of a generic parent.
The operations to include in your child package are listed below.
Notice the difference between the function and procedure versions
of toUpper
and removeNonLetter
.
For this assignment, letters are defined to be any Characters in the ranges
'a' .. 'z' and 'A' .. 'Z'; any other character is a non-letter.
You might want to check out the package
Ada.Characters.Handling
as you work on the assignment.
So that your code can be tested, make sure that you
use the exact names listed below and the exact child package names.
In other words, do NOT make any changes to this specification.
Operations in the child packages are
generic package wordpkg.utilities is function to_Upper(w: Word) return Word; function remove_NonLetter(w: Word) return Word; procedure to_Upper(w: in out Word); procedure remove_NonLetter(w: in out Word); end wordpkg.utilities; generic package wordpkg.palindromes is function is_Pal(w: Word) return Boolean; end wordpkg.palindromes;
Your client (named more_pals.adb
)
uses your packages to
report the palindrome status (explained below) of zero or more phrases.
You may end up not using all of the routines in WordPkg.Palindromes to complete the assignment
but you are to implement them all anyway. You will, of course, also want to test
all of your routines!
Your client should
call the get
routine from wordpkg to read zero or more phrases from standard input.
If a phrase is longer than the maximum word length,
then your program
should immediately print an appropriate error message and halt (but not crash) — that is, the client should handle
the exception thrown from wordpkg
.
Standard Input:
Your program should read from stdin, which will be a sequence of phrases
with any amount of white space
allowed around any of the phrases.
The phrases themselves will not contain white space, although they can contain non-letters.
Your program should read from the input until it reaches end of file.
Remember that get from the word package returns a word of length 0 at end of file.
You should probably use this test rather than explicitly testing for end of file.
Output:
Output will include the original string, its status, and, possibly,
a modified string that is a
palindrome.
This output should be in the exact format that is shown in the sample run.
The palindrome status of a string is the first of the following that applies:
Palindrome as is
Palindrome when non-letters are removed
Palindrome when converted to upper case
Palindrome when converted to upper case and non-letters are removed
Never a palindrome
pals-in.txt
):
b madamimadam Madam-I-madaM madamImAdam maDamI'maDam! !madam.I'm.Adam? randomstring
rucs> pals < pals-in.txt String: b Status: Palindrome as is String: madamimadam Status: Palindrome as is String: Madam-I-madaM Status: Palindrome as is String: madamImAdam Status: Palindrome when converted to upper case PalStr: MADAMIMADAM String: maDamI'maDam! Status: Palindrome when non-letters are removed PalStr: maDamImaDam String: !madam.I'm.Adam? Status: Palindrome when converted to upper case and non-letters are removed PalStr: MADAMIMADAM String: randomstring Status: Never a palindromeSubmit: Using the command shown above, you will submit the files:
wordpkg.ads
(modified to be generic) wordpkg-utilities.adb
, with general-purpose word utilities wordpkg-palindromes.adb
, with palindrome-specific word function more_pals.adb
, your client. This is the only file that should call any I/O routines. wordpkg.adb, wordpkg-{utilities,palindromies}.ads
.
Note that when grading, I will be using your files along with the provided files,
and your files really do need to compile with those!