Starting from:
$35

$29

Assignment 05 The Strings Class and RememberingStrings Client (Using Arrays) Solution

Consider the given instance class, Strings.java, which abstracts a collection of strings. Consider further the corresponding client program, RememberingStrings.java, which prompts the user to enter “string values” which it then maintains in an instance of Strings.

This program is very similar in operation to the simple straightforward program, Remembering.java, which was developed near the end of class on Wed Apr 22nd. One major difference between these two programs is that the one developed in class maintained an “array of ints” in the program itself and thus it had to deal with all of the details of performing operations with that array. But that was the point, because it was meant to illustrate how to declare and use an array.

For this assignment, the Strings class has been designed to abstract a collection of Strings so as to relieve its clients from having to deal with any of the details of maintaining an “array of Strings”. Of course, the operations in both cases are very similar and necessary, but it is far better to encapsulate the details within classes than it is to require clients to have to deal with them.


Consider the sample execution shown to the right, which serves as an illustration of the operation of both the client and the corresponding class.

For this assignment, you are not to make any changes to the RememberingStrings.java program. Instead all of your work will be in the given Strings.java source program. You’ll note that most of the methods are stubbed, and so it will be necessary for you to provide implementations for these stubbed methods. Thus, the software as given, only behaves as illustrated below.


c:\C134>java RememberingStrings 8 (0:?)

Enter a string:>Hello (0:?)

Enter a string:>Hello (0:?)
Enter a string:>Bye

(0:?)
Enter a string:>

Done!

Realize that although all of the required public methods of the class have been designed for you, there may well be additional private methods that you might want to develop in the class.

Be sure to fully augment the comments in the source program, Strings.java, which in part means inserting and completing the required comment block at the beginning and by also providing other appropriate and useful comments as needed.
When done you are to submit just your revised Strings.java file to the AS05 folder on the CMPS134 CWS.

More products