Complete the implementation of BlurbGenerator.java, which is called from Blurbs.java. The incomplete methods are makeWhoozit() makeYString() makeWhatzit() Submit BlurbGenerator.java. Blurbs.java /**  * Solution to Programming Project 17.5  *   * @author Java Foundations  */ import java.util.Scanner;   public class Blurbs { /** * Generates a series of Blurbs (a word in an alien language). */   public static void main(String args[]) {     BlurbGenerator blurbMaker = new BlurbGenerator();     Scanner scan = new Scanner(System.in);       System.out.println("How many blurbs would you like? ");     int numBlurbs = scan.nextInt();       for (int i = 1; i <= numBlurbs; i++) {       System.out.println("Blurb #" + i + ": " + blurbMaker.makeBlurb());     }   } }   BlurbGenerator.java import java.util.Random; /**  * In the language of an alien race, all words take the form of Blurbs.  * A Blurb is a Whoozit followed by one or more Whatzits.  * A Whoozit is the character 'x' followed by zero or more 'y's.  * A Whatzit is a 'q' followed by either a 'z' or a 'd', followed  * by a Whoozit.  *   * Solution to Programming Project 17.5  *   * @author Java Foundations  */ public class BlurbGenerator {   private Random gen;   /**    * Instantiates a random number generator needed for blurb creation.    */   public BlurbGenerator() {     gen = new Random();   }   /**    * Generates and returns a random Blurb. A Blurb is a Whoozit    * followed by one or more Whatzits.    */   public String makeBlurb() {     return makeWhoozit() + makeMultiWhatzits();   }   /**    * Generates a random Whoozit. A Whoozit is the character 'x'    * followed by zero or more 'y's.    */   private String makeWhoozit() {     System.out.println("makeWhoozit() unimplemented.");     String whoozit = "";     return whoozit;   }   /**    * Recursively generates a string of zero or more 'y's.    */   private String makeYString()   {     System.out.println("makeYString() unimplemented.");     String yString = "";     return yString;   }   /**    * Recursively generates a string of one or more Whatzits.    */   private String makeMultiWhatzits() {     String whatzits = makeWhatzit();     if (gen.nextBoolean()) {       whatzits += makeMultiWhatzits();     }     return whatzits;   }   /**    * Generates a random Whatzit. A Whatzit is a 'q' followed by    * either a 'z' or a 'd', followed by a Whoozit.    */   private String makeWhatzit() {     System.out.println("makeWhatzit() unimplemented.");     String whatzit = "";     return whatzit;   } } // class BlurbGenerator

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Complete the implementation of BlurbGenerator.java, which is called from Blurbs.java. The incomplete methods are

    • makeWhoozit()
    • makeYString()
    • makeWhatzit()

Submit BlurbGenerator.java.

Blurbs.java

/**
 * Solution to Programming Project 17.5
 * 
 * @author Java Foundations
 */
import java.util.Scanner;
 
public class Blurbs {
/**
* Generates a series of Blurbs (a word in an alien language).
*/
  public static void main(String args[]) {
    BlurbGenerator blurbMaker = new BlurbGenerator();
    Scanner scan = new Scanner(System.in);
 
    System.out.println("How many blurbs would you like? ");
    int numBlurbs = scan.nextInt();
 
    for (int i = 1; i <= numBlurbs; i++) {
      System.out.println("Blurb #" + i + ": " + blurbMaker.makeBlurb());
    }
  }
}
 
BlurbGenerator.java

import java.util.Random;
/**
 * In the language of an alien race, all words take the form of Blurbs.
 * A Blurb is a Whoozit followed by one or more Whatzits.
 * A Whoozit is the character 'x' followed by zero or more 'y's.
 * A Whatzit is a 'q' followed by either a 'z' or a 'd', followed
 * by a Whoozit.
 * 
 * Solution to Programming Project 17.5
 * 
 * @author Java Foundations
 */
public class BlurbGenerator {
  private Random gen;
  /**
   * Instantiates a random number generator needed for blurb creation.
   */
  public BlurbGenerator() {
    gen = new Random();
  }
  /**
   * Generates and returns a random Blurb. A Blurb is a Whoozit
   * followed by one or more Whatzits.
   */
  public String makeBlurb() {
    return makeWhoozit() + makeMultiWhatzits();
  }
  /**
   * Generates a random Whoozit. A Whoozit is the character 'x'
   * followed by zero or more 'y's.
   */
  private String makeWhoozit() {
    System.out.println("makeWhoozit() unimplemented.");
    String whoozit = "";
    return whoozit;
  }
  /**
   * Recursively generates a string of zero or more 'y's.
   */
  private String makeYString()
  {
    System.out.println("makeYString() unimplemented.");
    String yString = "";
    return yString;
  }
  /**
   * Recursively generates a string of one or more Whatzits.
   */
  private String makeMultiWhatzits() {
    String whatzits = makeWhatzit();
    if (gen.nextBoolean()) {
      whatzits += makeMultiWhatzits();
    }
    return whatzits;
  }
  /**
   * Generates a random Whatzit. A Whatzit is a 'q' followed by
   * either a 'z' or a 'd', followed by a Whoozit.
   */
  private String makeWhatzit() {
    System.out.println("makeWhatzit() unimplemented.");
    String whatzit = "";
    return whatzit;
  }
} // class BlurbGenerator

 

Expert Solution
Step 1

Algorithm:

  1. The BlurbGenerator class initializes a Random generator.
  2. The makeBlurb() method returns a random Whoozit followed by one or more Whatzit generated by the makeMultiWhatzits() method.
  3. The makeWhoozit() method returns the string "x" followed by zero or more "y" generated by the makeYString() method.
  4. The makeYString() method recursively generates a string of zero or more "y". If a random boolean value is true, it adds a "y" to the string and calls itself again.
  5. The makeWhatzit() method generates a Whatzit which starts with the string "q" and appends either "z" or "d" depending on a random boolean value. It then calls makeWhoozit() to generate the rest of the Whatzit.
  6. The makeMultiWhatzits() method generates a string of one or more Whatzit using makeWhatzit(). If a random boolean value is true, it appends the result of a recursive call to itself. It returns the concatenated string of all the Whatzit generated.
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Generic Type
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY