Coder Social home page Coder Social logo

wordcount's Introduction

wordcount

using System; using System.IO; public class WordCountEntry { static void Main(string[] args) { if (args.Length==0) { display_usage(); return ; } else /* bool traceOn=false; bool spyOn=false; foreach ( string option in args ) { if (option.Equals("-t")) traceOn=true; else if(option.Equals("-s")) spyOn=true; else if(option.Equals("-h")) {display_usage(); return; } else Cosole.WriteLine("check_valid_file_type(option)"); }/ Console.WriteLine( "Beginning WordCount program ... " ); WordCount theObj = new WordCount(); theObj.processFile(); Console.WriteLine( "Ending WordCount program ... " ); } public static void display_usage() { string usage= @"usage:WordCount[-s] [-t] [-h] textfile.txt where[] indicates an optional argument -s prints a series of performance measurements -t prints a trace of the program -h prints this message"; Console.WriteLine(usage); } } public class WordCount { public void processFile() { openFiles(); readFile(); countWords(); writeWords(); } private void countWords() { Console.WriteLine( "!!! WordCount.countWords()" ); } private void readFile() { / string text_line; while ((text_line=freader.ReadLine() )!=null) { //write to output file fwriter.WriteLine(text_line ); } //must explicitly close the readers freader.Close(); fwrriter.Close();/ Console.WriteLine( "!!! WordCount.readFile()" ); } private void openFiles() { string file_name=@"a.txt"; StreamReader freader=File.OpenText(file_name); StreamWriter fwriter=File.CreateText(@"a.diag"); Console.WriteLine( "!!! WordCount.openFiles()" ); } / public static void display_usage() { string usage= @"usage:WordCount[-s] [-t] [-h] textfile.txt where[] indicates an optional argument -s prints a series of performance measurements -t prints a trace of the program -h prints this message"; Console.WriteLine(usage); }*/ private void writeWords() { Console.WriteLine( "!!! WordCount.writeWords()" ); } }

wordcount's People

Contributors

sxue avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.