Question: Create a class called ListOfThings, that has one ArrayList field called things, which holds a collection of Strings (each string is a name of

Create a class called ListOfThings, that has one ArrayList field called things,

Create a class called ListOfThings, that has one ArrayList field called things, which holds a collection of Strings (each string is a name of an object in Upper case e.g. CAR or PLANT). Make sure you write a description of your new Class in the comments, with your name as author and give the version as the date you last worked on this exercise. Define a constructor that initialises the ArrayList. Note that you can also add any other initialisations that you feel are relevant. 4 Create methods to add elements, remove elements and get the number of elements in the collection. Add a test for all three of these methods to check whether the operation was successful and print a message letting the user know if it was or was not. Create a method called printThings. This method should loop through the collection and print out the elements (each String on a new line) as determined by the following rules: If the string contains any vowels (A, E, I, O and U), the method should print "The object '+ the value of the String + " contains vowels, and the vowels are:" + list of the vowels in the string. The string may have more than one vowels. For example, if the name is BIKE it would print: The object BIKE contains vowels, and the vowels are: I E If the string contains duplicate characters, the method should print "The object " + the value of the String + " has the following duplicate character(s):" + list of the duplicate characters in the string. The string may have one or more duplicate character. For example, if the object is RACETRACK, it would print: The object RACETRACK has the following duplicate character(s): R A C If the string contains any vowels (A, E, I, O and U), and it has duplicate characters, the method should print "The object " + the value of the String + " contains vowels and has duplicate characters". For example, if the object is PIZZA it would print: The name PIZZA contains vowels and has duplicate characters. If none of the above criteria is met, then the method should print the String element in lower case. For example, if the object is SKY, it would print: sky Once you have finished your project, open the terminal window in BlueJ and turn on record method calls. Create a new ListofThings object, and then add at least eleven (11) Strings using the add method you wrote. You must have: A String that contains vowels A String that has duplicate characters A String that contains vowels and has duplicate characters Demonstrate removing an element using the remove method you wrote, and then find the number of elements using the method you wrote that gets the number of elements. Finally, run your printNames method.

Step by Step Solution

3.43 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 Create a class called ListOfThings Java public class ListOfThings 2 Add an ArrayList field called things Java public class ListOfThings private ArrayList things 3 Define a constructor that initializ... View full answer

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 Programming Questions!