News Ticker

Menu

CS 211 Lab 5: Output, Inheritance, Censorship

CensoredWriter Overview

Occasionally in history there has arisen the need to censor communications. An automatic means of doing this is to scan output and block or replace certain key words that appear. We will set up a class CensoredWriter which performs this task: any output that contains a specified string pattern will have the pattern replaced by a censor string.

The solution will involve


  • Making CensoredWriter a child class of PrintWriter
  • CensoredWriter will then have print and println methods
  • CensoredWriter will change what the print and println methods do: it will transform input to them.
  • Transformations will be done in a special transform() method of the CensoredWriter. This is a method that the parent class PrintWriter does not have.
  • Transformations of output will utilize String class methods which will replace matched string patterns with the censored text
  • Transformed text will be passed to the parent class print and println methods which will perform the printing.
  • Several constructors for CensoredWriter will be provided so that output can be sent to the screen or to a file.
  • All other methods of CensoredWriter will be inherited from PrintWriter and will behave identically to the parent class.

The intended use for CensoredWriter is demonstrated below in an interactive session.

A class which acts like a PrintWriter but filters output of certain string patterns. It has several required elements.


  • Constructors to create CensoredWriters that write to System.out and to files. These constructors also accept a string pattern to censor.
  • A transform() method which will transform input strings for output. This method is public to allow for testing but is primarily used internally.
  • Overrides of print and println methods that transform() input text before calling the super class versions of these methods.


Getting Credit for this Lab


To receive credit for this lab you must submit a zip file of your files to Blackboard. Credit will be assigned based on the fraction of tests you pass. You may test your programs locally as well to ensure you know what your score will be ahead of time. Most students work on labs until they pass all tests then submit their code.

Grading Process: Graders will download your zip file, unzip it, change into the resulting directory and run a series of commands to compile and test your code. The exact commands are given in the below section. You can verify what your lab score will be by running those commands yourself. This is particularly relevant if you are using an IDE other than Dr. Java: it is your responsibility to verify that the tests pass on the command line. Test failures during grading will receive no credit and will not be examined for regrading.

After verifying that your code runs, zip your lab directory and submit it to Blackboard under the corresponding lab submission location.

Program Images





So what are you waiting for? Buy the solution now and relax :D


Buy now

Share This:

Hassnain

I'm Hassnain. A full time Java Developer. I enjoy to make modern projects. I love to create JavaFX, Java Swing GUI and write about Java Programming, OOP. Now I'm working with CS2IT. You can buy our projects from here.

  • To add an Emoticons Show Icons
  • To add code Use [pre]code here[/pre]
  • To add an Image Use [img]IMAGE-URL-HERE[/img]
  • To add Youtube video just paste a video link like http://www.youtube.com/watch?v=0x_gnfpL3RM