Presentation is loading. Please wait.

Presentation is loading. Please wait.

Console applicatie static void Main ( ) class Hallo { } { } Console. WriteLine("Hallo " + naam + "!" ); statische methodestatische methoden Console. WriteLine("Wat.

Similar presentations


Presentation on theme: "Console applicatie static void Main ( ) class Hallo { } { } Console. WriteLine("Hallo " + naam + "!" ); statische methodestatische methoden Console. WriteLine("Wat."— Presentation transcript:

1 Console applicatie static void Main ( ) class Hallo { } { } Console. WriteLine("Hallo " + naam + "!" ); statische methodestatische methoden Console. WriteLine("Wat is je naam?"); string naam = Console. ReadLine( );

2 class Console static void WriteLine( string s ) class Console { } { } Console. Out. WriteLine( s ); static string ReadLine( ) { } return Console. In. ReadLine( ); TextReader In { get; } TextWriter Out { get; }

3 class TextReader abstract string ReadLine( ) ; class TextReader { } string ReadToEnd( ) { } string resultaat, regel; return resultaat; regel = this.ReadLine( ); while (regel != null) { } resultaat += regel + "\n" ; regel = this.ReadLine( ); TextReader StreamReader StringReader abstract

4 class TextReader abstract string ReadLine( ) ; class TextReader { } string ReadToEnd( ) { } string resultaat, regel; return resultaat; while (regel != null) { } resultaat += regel + "\n" ; regel = this.ReadLine( ); ( (regel = this.ReadLine()) != null ) en meteen testen regel = this.ReadLine( ); toekennen

5 Commandline programma $>date Fri Oct 29, 11:30 $> ls aap.txt hallo.doc prog.cs $> grep void prog.cs prog.cs, line 6: void Main() prog.cs, line 10: void teken() $>ls > files.txt $> parameters voor het programma output redirection

6 Voorbeeld file-processor nlaat alle regels van de files zien waarin het gegeven patroon voorkomt n(met filenaam en regelnummer) grep patroon file1 file2... Unix-commando

7 Grep: main class Grep if (params.Length==0) Console.WriteLine("Usage: java Grep pat file..."); else static void Main ( for (int t=1; t { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/8/2205763/slides/slide_7.jpg", "name": "Grep: main class Grep if (params.Length==0) Console.WriteLine( Usage: java Grep pat file... ); else static void Main ( for (int t=1; t

8 Grep: bewerk static void bewerk (String pat, String naam) { regel=buffer.ReadLine() Console.WriteLine( naam if ( regel. Contains (pat) ) reader = new StreamReader (naam); TextReader reader; String regel; while ()( ) != null ; n++ for (int n=1; + n+ regel ); if (naam=="") reader = Console.In; else try { } catch (Exception e) { Console.WriteLine(naam + e); }


Download ppt "Console applicatie static void Main ( ) class Hallo { } { } Console. WriteLine("Hallo " + naam + "!" ); statische methodestatische methoden Console. WriteLine("Wat."

Similar presentations


Ads by Google