Question: Create a class that extends Reader, and provides a new kind of Reader, a TrReader, that translates the characters from another Reader. That is, a

Create a class that extends Reader, and provides a new kind of Reader, a TrReader, that translates the characters from another Reader. That is, a TrReaders source of characters is some other Reader, which was given to the TrReaders construc- tor. The TrReaders read routine simply passes on this other Readers characters, after first translating them.

import java.io.Reader;

/** Translating Reader: a stream that is a translation of an * existing reader. */ public class TrReader extends Reader { /** A new TrReader that produces the stream of characters produced * by STR, converting all characters that occur in FROM to the * corresponding characters in TO. That is, change occurrences of * FROM.charAt(0) to TO.charAt(0), etc., leaving other characters * unchanged. FROM and TO must have the same length. */ public TrReader(Reader str, String from, String to) { // FILL IN }

// FILL IN // NOTE: Until you fill in the right methods, the compiler will // reject this file, saying that you must declare TrReader // abstract. Don't do that; define the right methods instead! }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!