Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Package Name: hmwk14 Source File Name: (Zip these files) Madlib.java MadlibTest.java Test Files: C2800_Ch14_Hmwk1_Madlibs_Test.zip Do you remember Madlibs? You the other person for some nouns,

Package Name:

hmwk14

Source File Name:

(Zip these files)

Madlib.java

MadlibTest.java

Test Files:

C2800_Ch14_Hmwk1_Madlibs_Test.zip

Do you remember Madlibs? You the other person for some nouns, adjectives, and verbs. You fill in the blanks with those words and it usually makes a funny story.

Make a Madlib class that will maintain everything related to the Madlib story. I recommend that this class include:

Instance variables for a Scanner and a String or StringBuilder to hold the story

Method to prompt and read the story

Method to replace a single placeholder This method should figure out what the prompt should be, prompt the user, and update the story with the word entered

Method to return the story or print the story

Make a MadlibTest class. This class will contain main() and it should be short.

Make a new Madlib object

Call the method to read the story

Call the method to change a single placeholder. Do this 5 times. Right now all of our stories will have exactly 5 placeholders

Call a method to get or print the finished story so the user can see it

Placeholders:

When you read the initial story, it will have 5 placeholders. Each placeholder starts with an underscore (_)

The next character indicates the type of placeholder, N for noun, A for adjective, and V for verb

Ask for the placeholders in order they appear in the story

You need to somehow replace the placeholders with the users answers. All of this can be accomplished with the String and/or StringBuilder methods in this chapter.

Requirements:

Put System.out.println() after next, nextLine, call. This will help you match the Test Program and make it easier to use it.

You should not need any loops for this program. But you may want a loop to call the replace the single placeholder method 5 times.

Sample Run #1: (the highlighted text is what the user types)

Madlib? Today I went to the _N. I saw a _A _N _V on the _N.

Noun? store

Adjective? purple

Noun? monkey

Verb? jump

Noun? banana

Today I went to the store. I saw a purple monkey jump on the banana.

Extra Notes:

Did you correctly name the package/folder?

Did you correctly name the class/file?

Did you include comments?

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

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

Define Administration?

Answered: 1 week ago