project address | https://github.com/aSmallAlan/WordCount |
---|---|
Twinning partners | No twinning partners, as is the senior, junior partner did not know |
1.PSP table
PSP2.1 |
Personal Software Process Stages |
Estimated time consuming (minutes) |
The actual time-consuming (minutes) |
Planning |
plan |
30 |
20 |
· Estimate |
• Estimate how much time this task requires |
120 |
240 |
Development |
Develop |
60 |
200 |
· Analysis |
· Needs analysis (including learning new technologies) |
30 |
20 |
· Design Spec |
Generate design documents |
20 |
20 |
· Design Review |
· Design Review (and his colleagues reviewed the design documents) |
20 |
10 |
· Coding Standard |
· Code specifications (development of appropriate norms for the current development) |
10 |
20 |
· Design |
· Specific design |
30 |
20 |
· Coding |
· Specific coding |
120 |
240 |
· Code Review |
· Code Review |
20 |
10 |
· Test |
· Test (self-test, modify the code, submit modifications) |
20 |
20 |
Reporting |
report |
10 |
20 |
· Test Report |
· testing report |
10 |
10 |
· Size Measurement |
· Computing workload |
30 |
40 |
· Postmortem & Process Improvement Plan |
· Hindsight, and propose process improvement plan |
10 |
30 |
|
total |
570 |
650 |
2. Module Design
1. Define the global array, for storing information files will be written
public static string [] Information = { "", "", ""}; // definition of the three types of information written to the file
2. The statistical method the number of characters
int charCount public (String fileName) { the FileStream new new FS = the FileStream (fileName, FileMode.Open); // open the file string wordsNumber = Convert.ToString (fs.Length); // read-out length information in the file, i.e., the number of characters fs.Close (); Console.Write ( "character statistics success"); return int.Parse (wordsNumber); // returns the number of characters read out }
3. the number of words of statistics
int the WordCount public (String fileName) { the FileStream new new FS = the FileStream (fileName, FileMode.Open); // open file StreamReader sr = new StreamReader (fs, Encoding.Default); // read the file information in a particular manner string s = sr.ReadToEnd (); // read all the information fs.Close (); sr.Close (); char [] = {C '', ',', ','}; // definition of skipped characters type string [] words = s.Split (c , StringSplitOptions.RemoveEmptyEntries); // read-out information according to the type of characters to skip, into a string Console.Write ( "success word count"); return words.Length ; // returns the number of the string, i.e. the number of words }
4. number of statistics rows
The method of the number of line statistics // public int RowsCount (String fileName) { the FileStream new new FS = the FileStream (fileName, FileMode.Open); // open file StreamReader sr = new StreamReader (fs, Encoding.Default); // a particular manner reading the file information string s = sr.ReadToEnd (); // read all the information fs.Close (); sr.Close (); char [] = {C '\ n-'}; // skip defined character type, line breaks string [] words = s.Split (c , StringSplitOptions.RemoveEmptyEntries); // read-out information according to the type of characters to skip, into a string Console.Write ( "row counting success") ; return words.Length; // returns the number of the string, i.e., rows }
5. The method of writing to a file
void WriteIn public () { the FileStream the FileStream new new FS = ( "F.: the result.txt \\", FileMode.Create); // file defines the type of operation, examples of StreamWriter sw = new StreamWriter (fs) ; // a particular manner writing information instantiated for (int i = 0; i <. 3; i ++) { sw.Write (information [i]); // write the i-th information sw.Write ( "\ r \ n" ); // wrap } sw.Flush (); sw.Close (); fs.Close (); Console.Write ( "file successfully written"); }
Character counts, count the number of words, lines statistics, file write these four functions are to write a method defined in a class, call these methods in the main function inside
3. Test