From ab56ec55580aa994f0b2f0cc369b9d877443d07e Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Thu, 31 Aug 2023 13:13:25 -0400 Subject: [PATCH] updating README --- hws/01_text_justification/README.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/hws/01_text_justification/README.md b/hws/01_text_justification/README.md index 79ad5a9..b25fe70 100644 --- a/hws/01_text_justification/README.md +++ b/hws/01_text_justification/README.md @@ -5,15 +5,13 @@ Before starting this homework, make sure you have read and understood the Academ This homework assignment is a programming exercise involving simple text manipulation to format input text into a framed column with a specified width. You will work with command line arguments, file input and output, and the C++ Standard Template Library string and vector classes. Please read the entire -assignment before starting to program. When you are ready to begin, create a subdirectory for homeworks -within your main Data Structures course directory and within that directory create a subdirectory hw1 for -this assignment. +assignment before starting to program. Your program will read words from an input file and greedily pack the words one at a time onto each line, making sure not to exceed the specified width. Your program will support three different methods for dealing -with any extra, unused space on each line. The first, flush left, simply positions each word as far to the left as -possible, leaving a gap of spaces (if any) on the right. The second, flush right, does the opposite, pushing all -the words to the right, and puts the extra spaces on the left. In the final mode, full justify, the extra spaces +with any extra, unused space on each line. The first, **flush left**, simply positions each word as far to the left as +possible, leaving a gap of spaces (if any) on the right. The second, **flush right**, does the opposite, pushing all +the words to the right, and puts the extra spaces on the left. In the final mode, **full justify**, the extra spaces are distributed evenly between the words. If the number of extra spaces on the line do not divide evenly into those “between” slots, the slots on the left will be assigned more spaces that the slots on the right. @@ -57,7 +55,7 @@ do not count towards the specified line width of the text. In other words, each in all three cases. The only difference is where the “extra” spaces appear. The top line has 6 extra spaces (16 - # of characters in “Here is an” = 6). In full justify mode, these spaces are evenly divided into the 2 slots between the 3 words. The second line has 1 extra space (16 - # of characters in “example of text” -= 1). This extra space is assigned to the leftmost of the two slots on the second line. Also note a typical += 1). This extra space (still in full justify mode) is assigned to the leftmost of the two slots on the second line. Also note a typical convention for full justify formatting: The last line of a block of text formatted with full justify is not forced to stretch all the way to the right edge. No extra space is inserted between words on the last line – it should be flush left justified only. @@ -71,7 +69,7 @@ commas, apostrophes, etc.) should be treated as part of the word if it is not se spaces. The basic iostream string input operator, >>, will work perfectly for this assignment. The output of your program will be written to a file, and should follow the specifications in this handout and match our examples. Reading and writing files in C++ is very similar to std::cin and std::cout. See examples of -STL file streams on the course webpage “Misc. C++ Programming Information”. +STL file streams on the course webpage [Programming Information](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/programming_information.php). ## Command Line Arguments @@ -79,17 +77,22 @@ Your program will expect 4 command line arguments. The first is the name of the the name of the output file. The third argument is an integer that specifies the width of the text column. The fourth argument will be a string (flush_left, flush_right, or full_justify) specifying which formatting mode should be used. Here are examples of valid command lines for your program: + +```console ./justify.exe example.txt example_16_flush_left.txt 16 flush_left ./justify.exe example.txt example_16_flush_right.txt 16 flush_right ./justify.exe example.txt example_16_full_justify.txt 16 full_justify +``` + You should implement very simple error checking to ensure that 4 arguments are provided and that the input and output file streams are successfully opened. You should also check that the values for the third and fourth arguments are valid. Your program should exit gracefully with a useful error message sent to std::cerr if there is a problem with the arguments. + You must follow the specifications for the command line, input file, and output file exactly to ensure you receive full credit from the Submitty homework submission autograder. We have provided sample input & output files on the course website. Examples of using command line arguments can be found on the course -webpage: “Misc. C++ Programming Information”. +webpage: [Programming Information](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/programming_information.php). ## Corner Cases @@ -109,10 +112,8 @@ to read. ## Submission Details Use good coding style when you design and implement your program. Organize your program into functions: -don’t put all the code in main! Be sure to read the “Homework Grading Criteria” as you put the finishing -touches on your solution. Be sure to make up new test cases to fully debug your program and don’t forget +don’t put all the code in main! Be sure to read the [Homework Policies](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/homework_policies.php) as you put the finishing touches on your solution. Be sure to make up new test cases to fully debug your program and don’t forget to comment your code! Use the provided template README.txt file for notes you want the grader to read. -You must do this assignment on your own, as described in the “Collaboration Policy & Academic Integrity” -handout. If you did discuss the problem or error messages, etc. with anyone, please list their names in your +You must do this assignment on your own, as described in the [Collaboration Policy & Academic Integrity](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/academic_integrity.php) page. If you did discuss the problem or error messages, etc. with anyone, please list their names in your README.txt file. Prepare and submit your assignment as instructed on the course webpage. Please ask a TA -if you need help preparing your assignment for submission or if you have difficulty writing portable code. +if you need help preparing your assignment for submission.