From ggc
|
01 packagepackage is used to name the directory or folder a class is in FA;
02 //start auto-imports
03 importimport means to make the classes and/or packages available in this program java.util.*;
04 //end auto-imports
05 importimport means to make the classes and/or packages available in this program wiki.Wiki;
06
07
08 /**
09 * This program rquests console entry of two file names; one forfor is a looping structure for repeatedly executing a block of code the
10 * sourece of text in which replacements will be made and the other file
11 * is the pairs of targets and replacements forfor is a looping structure for repeatedly executing a block of code the targets.
12 * The program then calls methods from the FileTransformer classclass is a group of fields and methods used for making objects that
13 * reads the files and returns the transformed text.
14 * @authorthis is the Javadoc tag for documenting who created the source code Frank Anderson */
15 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects TransformerTest
16 {open braces start code blocks and must be matched with a close brace
17
18 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args)
19 {open braces start code blocks and must be matched with a close brace
20 /** sourceFile is the name of the file containing text. */
21 String sourceFile=this assignment operator makes the left side equal to the right side"sf";
22 /** targetsFile is the name of the file containing text to be replaced and
23 * the text with which it will be replaced. */
24 String targetsFile=this assignment operator makes the left side equal to the right side"tf";
25 Scanner scanner =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Scanner(System.in);
26
27
28
29 System.out.println("Enter the name of the source file for text.");
30 sourceFile =this assignment operator makes the left side equal to the right side scanner.next();
31 System.out.println(sourceFile);
32 System.out.println("Enter the name of the file containing the replacements.");
33 targetsFile=this assignment operator makes the left side equal to the right sidescanner.next();
34
35 System.out.println(targetsFile);
36
37 System.out.println();
38 System.out.println();
39 System.out.println("The modified text is below:");
40 System.out.println();
41
42 FileTransformer model =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor FileTransformer();
43 model.setSourceFile(sourceFile);
44 //model.setSourceFile("SampleText.txt");
45 model.addReplacements(targetsFile);
46 //model.addReplacements("SampleReplacements.txt");
47 System.out.println(model.getTransformedText());
48 }close braces end code blocks and must match an earlier open brace
49 }close braces end code blocks and must match an earlier open brace
|
Download/View FA/TransformerTest.java