Lab 1480 - Wonderland


There once was a little girl named Rhonda. She liked to read books, but they were always about someone she didn't know: children named Alice or Cinderella. So Rhonda hired you to write a program that would change the name in the books (e-texts, of course) to her name. For example, "Alice in Wonderland" would become "Rhonda in Wonderland" and all references to Alice would be changed to Rhonda.

File Input and Output

In this project, you will be reading from data files. There are many ways in Java to do file-io. We will use the chn utility package. Examples will help and may serve as prototypes for this project. I have provided examples of file input using a data file of integers, file output that generates a data file, and file copy, in this example translating the input file to upper case.


Write a class MyStory that has a constructor that has these parameters:
   public MyStory(String infileName, String oname, String nname)
   infileName is the name of the book source file.
   oname is the original name in the book, such as Alice
   nname is the new name in the book.

The class also has a translate method to do the conversion and to create an output file with the same name as the original but with the letters "my" prepended.

The test program,, should look like this:

import chn.util.*;

public class TestMyStory
  public static void main (String[] args)
      MyStory ms = new MyStory("Wonderland.txt", "Alice", "Rhonda");
Submit your code for after you have tested it with at least two of Rhonda's e-books. So you don't have to borrow her books, here is a copy of Alice in Wonderland and a copy of Through the Looking Glass.
Copyright © 2010 by Asylum Computer Services LLC Return to CS Labs