Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class WorkingWithBags { // instance variables should be created/initialized by the constructor private BagInterface bagOfStrings; private BagInterface bagOfVowels; // constants should be initialized at

public class WorkingWithBags

{

// instance variables should be created/initialized by the constructor

private BagInterface bagOfStrings;

private BagInterface bagOfVowels;

// constants should be initialized at the definition level

final BagInterface ALL_VOWELS = new ResizableArrayBag<>(new String[]{"a", "e", "i", "o", "u"});

final int MAX_NUMBER_OF_STRINGS_TO_GENERATE = 41;

final int MIN_NUMBER_OF_STRINGS_TO_GENERATE = 35;

final int MAX_STRING_LENGTH = 3;

final int MIN_STRING_LENGTH = 1;

/**

* constructor creates this.bagOfStrings and this.bagOfVowels objects

*/

public WorkingWithBags()

{

// TODO

} // default constructor

/**

* Adds the given entry to this.bagOfStrings if valid

*

* throws InvalidParameterException exception if the length of the string is outside the given bounds

* throws InvalidParameterException exception if the string contains characters other than lowercase letters

*/

public void addToBagOfStrings(String newEntry) throws InvalidParameterException

{

// TODO

}

/**

* Generates randomly string objects and adds them to this.bagOfStrings

*/

public void generateStrings()

{

System.out.println("*** Generating strings ***");

final int SEED = 41;

final int ASCII_LOWERCASE_A = 97;

final int ASCII_LOWERCASE_Z = 122;

Random random = new Random(SEED);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions