Question: Java Programming In this lab students continue to write programs using multiple classes. By the end of this lab, students should be able to Write

Java Programming

In this lab students continue to write programs using multiple classes. By the end of this lab, students should be able to

Write classes that use arrays and ArrayLists of objects as instance variables

Write methods that process arrays and ArrayLists of objects

Write getter and setter methods for instance variables

Write methods using object parameters and primitive types

Question-

class StringSet. A StringSet object is given a series of up to 10 String objects. It stores these Strings (or a reference to them, to be precise) and can perform limited calculations on the entire series.

The StringSet class has the following specification:

// an instance variable of type String[] // an int instance variable that indicates the number of String objects that the StringSet currently contains // a single no-argument constructor // a mutator that adds a String newStr to the StringSet object void add(String newStr) 
// an accessor that returns the number of String objects that have been added to this StringSet object int size() // an accessor that returns the total number of characters in all of the Strings that have been added to this StringSet object int numChars() // an accessor that returns the number of Strings in the StringSet object that have exactly len characters int countStrings(int len) Write a class StringSetTester that has a main method. It should ask the user for the number of Strings to add to a StringSet object. Afterward, use StringSet's size and numChars methods to print information about the collection of Strings entered. Also print the number of Strings that are exactly 5 and 7 characters long. Hint: because Scanner's nextInt and nextLine process whitespace differently, you may want to use code similar to the following Scanner kybd = new Scanner(System.in); System.out.print("How many strings will you enter? "); int numStr = kybd.nextInt(); // stops after the number, leaves end of line or other whitespace kybd.nextLine(); // "eats" everything up to and including the next newline // the next kybd.nextLine() will read user input 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!