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

Slides:



Advertisements
Similar presentations
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
Advertisements

I/O Basics 12 January 2014Smitha N. Pai, CSE Dept.1.
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
1 Streams and Input/Output Files Part 2. 2 Files and Exceptions When creating files and performing I/O operations on them, the systems generates errors.
Lecture 10 Methods COMP1681 / SE15 Introduction to Programming.
C++ crash course Class 10 practice problems. Pointers The following function is trying to swap the contents of two variables. Why isnt it working? void.
Data Structures ADT List
1 / / / /. 2 (Object) (Object) –, 10 (Class) (Class) –, –, – (Variables) [ Data member Field Attribute](, ) – (Function) [ Member function Method Operation.
Procedural Programming in C# Chapters Objectives You will be able to: Describe the most important data types available in C#. Read numeric values.
1 StringBuffer & StringTokenizer Classes Chapter 5 - Other String Classes.
HM-ES-th1 Les 7 Hardware/Software Codesign with SystemC.
Vervolg C Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1 Onderwerpen voor vandaag Dallas one-wire interface Opgave:
Reading and Writing Text Files Svetlin Nakov Telerik Corporation
1 public class Newton { public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t)
Code Correctness, Readability, Maintainability Svetlin Nakov Telerik Corporation
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Copyright © Recursive GCD Demo public class.
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
I/O & Perintah Dasar Linux Onno W. Purbo
Phil Campbell London South Bank University Java 1 First Steps.
Execute Blocks of Code Multiple Times Svetlin Nakov Telerik Corporation
Mr. Wortzman.  So far, we have gotten all our input and written all our output to the console  In reality, this is somewhat uncommon  Instead, we often.
Vervolg C Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1 Onderwerpen voor vandaag functie definitions;.h files;
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Chapter 10 Ch 1 – Introduction to Computers and Java Streams and File IO 1.
static void Main() { int i = 0; if (i == 0) { int a = 5; int b = 15; if (a == 5) { int c = 3; int d = 99; }
Onderwerpen voor vandaag
2 nd Semester Selection Statement Computer and Programming (204111)
How do Methods Work?. Let’s write a method that adds two integer values together and returns the result.
Formal Language, chapter 4, slide 1Copyright © 2007 by Adam Webber Chapter Four: DFA Applications.
Execute Blocks of Code Multiple Times Telerik Software Academy C# Fundamentals – Part 1.
Objects contains data and methods Class – type of object Create class first Then object or instance String – defined class String s; // creates instance.
Değişik Parametreli Nesne Tanımı 1. Object with parameter Class Box { double width; double height; double depth; Box(Box ob) { width=ob.width; height=ob.height;
Computer and Programming
Arrays Session 05 Mata kuliah: M0874 – Programming II Tahun: 2010.
Files & Streams. Files Introduction Files are used for long-term retention of large amounts of data, even after the program that created the data terminates.
Overloading methods review When is the return statement required? What do the following method headers tell us? public static int max (int a, int b)
Two Ways to Store Data in a File Text format Binary format.

C# B 1 CSC 298 Writing a C# application. C# B 2 A first C# application // Display Hello, world on the screen public class HelloWorld { public static void.
1 14/10/58Dr.Mud-Armeen Munlin 1 Files and Streams ผศ. ดร. หมัดอามีน หมันหลิน Faculty of IST, MUT
File I/O Static void Main( ) {... } data. Topics I/O Streams Reading and Writing Text Files Formatting Text Files Handling Stream Errors File Pointers.
String and Scanner CS 21a: Introduction to Computing I First Semester,
Openen en Opslaan class Tekst : Form { } TextBox invoer; void lees (string naam) { } void schrijf (string naam) { } StreamReadersr = new StreamReader (naam);
CSI 3125, Preliminaries, page 1 Compiling the Program.
Zet GeoICT aan het werk! Ruimte voor bodem Andreas Hoogeveen 12 november 2015.
CSC 298 Streams and files.
Bart van Kuik Application Developer Oracle Corporation.
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
Announcements Final Exam: TBD. Static Variables and Methods static means “in class” methods and variables static variable: one per class (not one per.
Computer Programs CS 1400 Dennis A. Fairclough Version 1.1 CS 1400 Dennis A. Fairclough Version 1.1.
Module 13: Properties and Indexers. Overview Using Properties Using Indexers.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Files and Streams Lec Introduction  Files are used for long-term retention of large amounts of data, even after the program that created the.
File Output Writing data out to a file 1. Output to files  StreamWriter : An object in the System.IO namespace that lets you print output to a destination.
Lecture 18 File I/O Richard Gesick. File Input / Output Consider that a program may want to make its data persistent (or not rely upon the user for input)
Methods Matthew Harrison. Overview ● There are five main aspects of methods... ● 1) Modifiers – public, private ● 2) Method Name ● 3) Parameters ● 4)
JAVA API Strings, I/O, Formatting and Parsing
Gameprogrammeren: Klassen en objecten in Painter
Part I General Principles
typedef typedef int Index; typedef char Letter; Index i; i = 17;
null, true, and false are also reserved.
TO COMPLETE THE FOLLOWING:
CS 190 Lecture Notes: Tweeter Project
Files & Streams.
Cs212: DataStructures Computer Science Department Lab 3 : Recursion.
Java Lesson 36 Mr. Kalmes.
Recursive GCD Demo public class Euclid {
Lecture 16 File I/O Richard Gesick.
Encapsulation.
CS1S467 GUI Programming LECTURE 14 Methods (1 of 2)
Presentation transcript:

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

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; }

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

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

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

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

Grep: main class Grep if (params.Length==0) Console.WriteLine("Usage: java Grep pat file..."); else static void Main ( for (int t=1; t<params.Length; t++) Grep.bewerk( params[0], params[t] ); { } { )string [ ] params

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); }