Purchase Solution

Java class for creating canned messages and random messages

Not what you're looking for?

Ask Custom Question

You will create the ShoutBox class for your Virtual World. Your ShoutBox class will have two methods:

Method shoutOutCannedMessage() will return type String. The shoutOutCannedMessage will use an Array or an ArrayList to store 10 messages of type String. For those of you who are more advanced with your Java skills, you could use a HashMap for the data structure. You can load this data structure with 10 messages of your choosing. You can initialize your Array or ArrayList with the messages or have the user enter the messages. The choice is yours. shoutOutCannedMessage() will loop through the data structure to first display all canned messages and allow the user to select one. The shoutOutCannedMessage() will return the selected message String.

The shoutOutRandomMessage() method will return type String.

The shoutOutRandomMessage() will use several Arrays or an ArrayList to store words. You will have one data structure that holds a list of words that are subjects, another data structure that holds a list of words that are objects, another that holds a list of verbs, another that holds a list of adverbs, and another that holds a list of adjectives. You can initialize your data structures with words or have the user enter the words. The choice is yours.

The shoutOutRandomMessage() method will use a random number generator that selects one word from each data structure to form a random message. The shoutOutRandomMessage() method will return the random message as a String data type. Random messages will be of the form: Subject - Verb - Adjective - Object - Adverb. Document your shoutOutRandomMessage() method to explain the code.

Purchase this Solution

Solution Summary

Use Java ArrayLists to create and display messages to the user. Have the user select a message. Also, use ArrayLists and random numbers to randomly generate a message. As a side note, this worked just fine when I tested it, multiple times.

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic Networking Questions

This quiz consists of some basic networking questions.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.