案例Java:Big Program 2: TextManipulator
当前位置:以往案例 > >案例Java:Big Program 2: TextManipulator
2018-08-29

Big Program 2: TextManipulator


In this project, you create a text-menu-driven program that reads text files and manipulates the input as directed by the user via the text menu. In addition, the program will both display the modifications on the screen and save them to a file.


The program will perform up to 4 manipulations:


1. Translation: Convert the inputted words to a mapped word as specified by a dictionary file.


2. To Pig Latin: Manipulate each word according to simplified rules for the argot Pig Latin (see the method header of pigLatin.


3. Reverse the letters of each word.


4. Reverse the words on each line.


The program will perform the manipulations as chosen by the user but always in the order specified above. If the user chooses all the manipulations, then the original word is first translated; the translation is modified according to the rules of pig latin; the pig latin of translation is then reversed; and, finally, the reversed pig latin of the translation of each word is reversed for each line.


The main menu will look as follows:


——————————————————————————–


Text Manipulator Program


——————————————————————————–


Current input file: —


Current output file: —


Current dictionary: —


Current mode: Modified


Current mods:


——————————————————————————–


Main menu:


1) Display Output


2) Save Output Manipulations:


T)ranslate P)ig latin W)ord reverse L)ine reverse


Configuration: I)nput file. O)utput file. D)ictionary file. M)ode Toggle. H)ide/show Menu.


Q)uit


Enter action:


Over the 3 milestones, you will implement the different menu options (1,2,T,P,W,L,I,O,D,M, and H) and the associated methods. Some sample operations of the program are: Output1.txt, Output2.txt, and Output3.txt.



This project is organized into three weekly milestones (Milestone 1, Milestone 2, Milestone 3). Feedback for your progress through these weekly milestones is available through zyBooks chapters 12, 13, and 14, where you will submit your weekly progress. At the end of milestone 3, December 7th at 11:59pm, your final progress will be further graded by both additional automated tests and human graders.


Unlike BP1, this is program is to be done individually.


All the files are encoded in UTF-8. Make sure that you download them as UTF-8. The safest way is to us the “Save link as…” option. This is particularly important for TextManipulator.java, Output2.txt, and OneFishDict.txt.


To verify the encoding is correct in those files, check that the lines in your downloaded file match the following:


TextManipulator.java

Line 317:

* Où

est la bibliothèque ?

Output2.txt

Line 113:

Ça un(e)

avoir un(e) petit(e) étoile .

OneFishDict.txt

Line 2:

are   être




Learning Goals


Your learning goals for this project include:


● Incrementally develop a complete Java application from a high-level specification.


● Design algorithms that account for basic input, output, storage, and processing.


● Iteratively test and debug code throughout the development process.


● Document code with comments and appropriate styling according to the class guides.


● Learn how methods improve code by making it modular and task-oriented.


● Implement a program that uses multiple static methods.


● Implement helper methods


● Implement methods that call other methods.


● Practice passing arguments to methods.


● Practice returning values from methods.


● Develop code using arrays and ArrayList (both 1D and 2D).


● Practice modifying arrays and ArrayLists within methods.


● Utilize a single Scanner object to read input from the console.


● Perform input validation on the user’s input.


● Practice reading and parsing data from files.


● Practice saving data to files.



Program Grading


Weekly Milestone

Program compiles and passes the weekly automated tests in zyLabs. Each weekly

Progress 36%

milestone is accompanied by some automated tests whose total value will be 12% of

your total program grade. If you don’t immediately pass these tests, you may upload

new submissions every half hour, and your highest scoring submission prior to the

deadline will be recorded.

Final Program

Program compiles and passes additional additional automated tests for both




Functionality 34%

functionality and conformance to the program specification. Your program should use

features covered from Chapter 1 to 11, but not beyond Chapter 11. For example, don't

use: additional Classes, or creating non-static Methods. Do not use class (static) or

instance (non-static) variables. Pass information between methods using parameters

and return values.

Program

Based on your TestMineSweeper.java that you wrote for BP1, you will write a

Verification 6%

TestTextManipulation.java that has at least 4 tests for each of the following methods:

matchCase, translate, pigLatin, reverse(String), reverse(ArrayList),

manipulate.

Style and Structure

Program uses appropriate variable names, spacing, control structures, etc. in

14%

conformance with the CS 200 Style Guide, and to make your code easier to read. Key

elements of style expected for this program:

●  4 space indenting for each level of nesting

●  Vertical whitespace (organize code into meaningful parts)

●  Horizontal whitespace (more readable statements)

●  Column limit: 100 characters (wrap with extra indent)

●  1 statement per line

●  Consistent formatting and use of braces

●  Descriptive names

●  Names follow conventions (CONSTANT, ClassName, variableName)

●  Use of constants instead of magic numbers (literals such as 3.1415, 7, etc)

Information is passed between methods using parameters and return values, no class

(static) or instance (non-static) variables are used. (Except for constants provided in

Config.java.)

Duplicated code is avoided by creating and using methods appropriately. If additional

methods are created they are marked as private. The main method calls the various

methods as appropriate.

Program doesn't use features beyond Chapter 11: File Input / Output such as:

additional Classes, or creating non-static Methods.

Documentation

Program is appropriately commented in a way that is meaningful for readers who

10%

understand Java, but are unfamiliar with what your program is doing and why. These

comments should conform to the CS 200 Style Guide. Key documentation expected for

this program:

●  Each file has a file header comment

●  Each class has a class header comment

●  Each method has a method header comment

●  Variable declarations briefly commented

●  Comments within methods (highlight major steps, explain long calculations,

clarify unusual code)


Working Together


Acceptable




With others you are encouraged to discuss:



● general algorithms


● the behavior or syntax for specific Java programming constructs


NOT Acceptable


With others you are NOT allowed to share code for this project in any form. All of the code that you submit with this project should be conceived-of and typed into the computer by you, or provided to you through the CS 200 website.


AVOID leaving any code in publicly accessible places, like: outside the L drive on a lab computer, on an unsecured computer, or on an unsecured website. Remember, all Piazza posts that include project code fragments must be marked private (visible only to Instructors).


Academic Integrity



Milestone 1: Menu, Reading and Displaying a File.


1. Create a new project in Eclipse. The name of the project does not matter, but TextManipulator would be a sensible choice.


2. Download Config.java and put in your project src folder. Look through the file to see the constants to use in your program. Whenever you need those values use the constants defined in Config.java. Our testing may use different values for these constants.


3. Download TextManipulator.java and put in your project src folder. This file contains all the methods necessary for all three milestones of this program. Detailed method headers are provided for you in the file. Implement the body of each method to meet the detailed descriptions in the method headers.


4. For milestone 1, implement the method bodies for the following methods keeping these exact method headers:

public static char promptMenu(Scanner sc, String[] files,


boolean[] modFlags, boolean modeBoth,


boolean showMenu)


public static String updateFileName(Scanner sc, String curFileName) public static void readInputFile(String fileName,


ArrayList fileByLine)


throws IOException


5. Partially implement


public static void display(ArrayList fileByLine,


ArrayList modFileByLine, boolean modeBoth) throws Exception


Specifically, the method should (regardless of the value of modeBoth) produce the output as if modeBoth is false.


6. For Milestone 1, an algorithm for the main method is: Begin the menu loop


Call the promptMenu


Process the action returned from promptMenu Exit the loop when prompt menu returns q or Q


The following menu options should be implemented in Milestone 1:



1 — Prints a line consisting of 80 Config.LINE_CHAboolean[] modFlagsR, followed by the output of display, followed by another line consisting of 80 Config.LINE_CHAR. The modified file should be generated when the user selects this option by calling the manipulate method. i,I — Calls the updateFileName to set the input text file path and name.


h,H — Toggles whether or not the full menu is displayed. See the details of the parameter showMenu in the promptMenu method header.

在线提交订单