Copy of IndividualProject-D4of4 (Spring 2024)

.docx

School

Georgia Institute Of Technology *

*We aren’t endorsed by this school

Course

6300

Subject

Computer Science

Date

May 11, 2024

Type

docx

Pages

13

Uploaded by JusticeIronDragon70 on coursehero.com

Unlike other assignments, this deliverable is not available to submit on Gradescope until the previous deliverable is due. That is, deliverable 4 will be available on Gradescope 48 hours after this assignment is released on Canvas. Individual Project: altertxt Deliverable 4 Project Goals In this project, you will be developing a Java application, altertxt , using an agile, test-driven development process across multiple deliverables. For this assignment you will use version 19 of the Java Development Kit. You will receive one grade for the entire project, but each deliverable must be completed by its own due date and all deliverables will contribute to the overall project grade. Note that each deliverable is equally weighed. Specification altertxt is a command-line utility written in Java with the following specification: Summary altertxt allows for simple text manipulation of the contents of a file. Syntax altertxt [OPTIONS] FILE Description The program altertxt performs basic text transformation on the lines of text from an input file. It is invoked as a command-line tool using the syntax described above , after compilation. The program writes the transformed text to the standard output and errors or usage messages to the standard error without modifying the input file. The FILE parameter is required and must be the last parameter as shown above. The only options allowed in the program, which are optional, delimited by the left [ and right ] brackets, may be provided in any order and are described as follows: Option Description -e <string> Exclude Lines : Exclude lines containing the given substring. This option is mutually exclusive with -x . The case sensitivity for the substring search is determined by -i. -r <old> <new> Replace String : Replaces the first instance of substring old in each line with string new . The case sensitivity
Option Description for the search of the old substring is determined by -i. -i Case Insensitive : Applies case insensitive matching when used with "Exclude Lines" and "Replace String". This option takes no parameters. -x Remove Empty Lines : Removes empty lines from the input file. This option is mutually exclusive with the -e option. An empty line is any line that is composed of the empty string "" immediately followed by a line separator. -n <padding> Add Line Numbers : Add a line number with numeric padding followed by a single space to the beginning of each line, where padding is an integer in the inclusive range of 1 to 9 specifying the minimum padding of the line number field. If the number of digits in the line number is less than the specified padding, zeros are left padded until the minimum padding is reached. If the number of digits in the line number is greater than the specified padding, the line number is never truncated . Line numbering should start at 1. -s <suffix> Add Suffix : Adds the string parameter suffix at the end of each line. Order of execution The last command-line parameter provided is always treated as the filename, as shown in the syntax section , while OPTIONS flags can appear in any order and parsed as they appear from left to right. This means that the following two commands are equivalent when executed on the command line: Example 1 altertxt -e test -s ..? input.txt Example 2 altertxt -s ..? -e test input.txt In the above examples, (Example 1) parses -e first, then -s , and finally input.txt while (Example 2) parses -s first, then -e , and finally input.txt. These two will result in the same output (assuming that the same input.txt is used for both) because the parsing of options is independent of their execution order . The order of execution for each option is given in the diagram below (note that the colors and border lines are there for 2
ease of viewing): The above diagram of the execution order of options can also be described as follows: 1. -i shall be processed first, as it determines global parameters of the computation. 2. If -e is present, and if -i is present , then -e shall exclude lines containing matched strings with case insensitive manner, and if -i is not present , then -e shall exclude lines containing exact matched strings with case sensitive manner, or if -x is present, then empty lines from the input file shall be removed. 3. If -r is present, then replacements are performed based on the option parameters, using a case insensitive search if -i is present . 4. If -n is present, then a line number is applied. 5. If -s is present, then a suffix shall be applied. Notes To keep this application simple, all errors shall result in the display of the standard usage message. This is shown in the syntax section above as well as in the files provided to you which are linked in the first deliverable . If options are repeated, only their last occurrence is applied. The Examples section below shows a case of repeated options. An empty input file shall produce an empty output. The Examples section below shows a case of an empty input file. You shall assume that the command line parameter strings will not contain newline characters ( \r , \n , \r\n ) as the behavior of the program would be platform dependent and may result in error during grading. Therefore there should be no test cases using these values as option parameters. Additionally, you may assume that your application will be called with valid String[] args. Specifying option -e with an empty string as the string parameter shall exclude all lines, resulting in an empty output. IMPORTANT: You are expected to infer the expected program behavior using the Gradescope provided information alone. Submitting an implementation that prints out the instructor-provided test inputs is unfair to your classmates and will result in a significant grade penalty . Program errors The last line of a non-empty input file must be terminated by a newline. If the 3 New!
non-empty input file does not terminate in a newline, the program shall generate an error. All parameters of program options are required and shall result in an error if omitted. This means that parsing an option that should include parameters but doesn't should result in an error. The Examples section below shows a case of missing option parameters. Specifying option parameters with the wrong type shall result in an error. Specifying option -i without -e or -r shall result in an error. Specifying option -i with parameters shall result in an error. Specifying options -e and -x simultaneously shall result in an error. Specifying option -n with a non-integer value or an integer out of range shall result in an error. Specifying option -s with an empty string or option -r with an empty string as the old parameter should result in error. Examples of Usage The examples described here can also be seen in JUnit 5 form on the MainTest.java file provided to you in the first deliverable . In the following, " " represents a newline 4
character. Example 1 altertxt sample.txt input sample.txt stdout nothing sent to stdout stderr nothing sent to stderr Example 2 altertxt -i sample.txt input sample.txt Hello, world!↵ How are you?↵ stdout nothing sent to stdout stderr Usage: altertxt [ -i | -e substring | -x | -r old new | -n padding | -s suffix ] FILE↵ Example 3 altertxt -r 02 two sample.txt input sample.txt Some words are: "one", "02", and "three"↵ stdout Some words are: "one", "two", and "three"↵ stderr nothing sent to stderr Example 4 altertxt -e Bird sample.txt input sample.txt Dog goes "woof".↵ Cat goes "meow".↵ 5
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help