Assignment 6 – Wacky Sentences

Maximum Points = 50

 

(Due before class on April 9, 2008) The purpose of this assignment is to use loops and arrays in Java to manipulate sounds. In this assignment, you will use:

“Wacky Sentences” are sentences of three of more words that are randomly constructed from at least three lists of words. An example of a text-based wacky sentence is Program 111 (pg. 419-420). Your program is going to create one or more wacky sentences using the actual sounds.

Write a Java program that

  1. reads data from three or more files (each file contains an integer followed by that many paths to .wav files of words). Use FileChooser.pickAFile to select the files.
    1. For example a file noun.txt might look like the following:

3

C:/mediasources/dog.wav

C:/mediasources/cat.wav

C:/mediasources/book.wav

  1. assigns each file containing a word to a Sound object.
  2. constructs a “wacky sentence” using one random sound from each file, and
  3. plays the “wacky sentence” using the explore method.

NOTE 1: Make sure the Sound holding the “sentence” is “big” enough to hold the combined sounds. Remember to include “silence” between sounds.

NOTE 2: Your program will need to use the Scanner class to read the data from each file:

Scanner scan = new Scanner (new File(fileName));.

You will need to include throws IOException (see program 118 (page 451) after each method that reads from a file or use a try-catch block (see program 102 (pages 397-399). File I/O requires import java.io.*; in addition to import java.util.Scanner;

NOTE 3: You may need throws SoundException to handles the creation of the Sounds.

NOTE 4: Lab 37 (http://csc.ColumbusState.edu/summers/NOTES/1301/labs/lab37.htm) covers some of the material for IO and try-catch.

Submit the .java file containing your program.

 

Grades are determined using the following scale:

Grading Rubric  (Word document)