Osnove programskog jezika C# Čas 5. Delegati, događaji i interfejsi

Similar documents
Osnove programskog jezika C#

Osnove programskog jezika C# Čas 4. Nasledjivanje 2. deo

PREDMET. Osnove Java Programiranja. Čas JAVADOC

pojedinačnom elementu niza se pristupa imeniza[indeks] indeks od 0 do n-1

Svi Java tipovi imaju ekvivalentan tip u jeziku Scala Većina Scala koda se direktno preslikava u odgovarajući Java konstrukt

Uvod u programiranje - vežbe. Kontrola toka izvršavanja programa

Događaj koji se javlja u toku izvršenja programa i kvari normalno izvršenje. Kada se desi izuzetak, sistem pokušava da pronađe način da ga obradi.

Vežbe - XII nedelja PHP Doc

namespace spojneice { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Programiranje III razred

PROGRAMIRANJE. Amir Hajdar

CSS CSS. selector { property: value; } 3/20/2018. CSS: Cascading Style Sheets

GUI - događaji (Events) i izuzeci. Bojan Tomić

Računarske osnove Interneta (SI3ROI, IR4ROI)

VRIJEDNOSTI ATRIBUTA

Izrada VI laboratorijske vježbe

PITANJA ZA II KOLOKVIJUM NASLJEĐIVANJE, VIRTUELNE FUNKCIJE I POLIMORFIZAM

NIZOVI.

var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin ListBox1.Items.LoadFromFile('d:\brojevi.

VHDLPrimeri Poglavlje5.doc

UPUTSTVO ZA KORIŠĆENJE NOVOG SPINTER WEBMAIL-a

JavaScript i HTML DOM

b) program deljiv3; uses wincrt; var i:integer; begin i:=3; while i<100 do begin write(i:5); i:=i+3; end; end.

Uputstva za instaliranje čitača Datalogic Skorpio u operativnom sistemu Windows 7 i višim POM-NA-XX-46, V3.0

Mašinska vizija. Dr Nenad Jovičić tnt.etf.rs/~mv

VB komande. Programiranje 1

Projektovanje Namenskih Računarskih Struktura 1. Sistemi zasnovani na Androidu

Programiranje Programski jezik C. Sadržaj. Datoteke. prof.dr.sc. Ivo Ipšić 2009/2010

Advanced Computer Programming

Programiranje III razred

Binarne hrpe. Strukture podataka i algoritmi VJEŽBE 26. siječnja / 133

UNIVERZITET U BEOGRADU ELEKTROTEHNIČKI FAKULTET

Uputa: Zabranjeno je koristiti bilo kakva pomagala. Rje²enja pi²ete desno od zadatka. Predajete samo ovaj list.

Učitati cio broj n i štampati njegovu recipročnu vrijednost. Ako je učitan broj 0, štampati 1/0.

OBJEKTNO ORIJENTISANO PROGRAMIRANJE

Variable Neighborhood Descent - VND (Metoda promenljivog spusta)

... ; ako je a n parno. ; ako je a n neparno

PROGRAMIRANJE. Teme. Packages Reference objekata Inheritance nasljeđivanje Exceptions. Amir Hajdar

Uvod u relacione baze podataka

PITANJA ZA II KOLOKVIJUM KLASE I OBJEKTI

x y = z Zadaci - procedure

24/03/2018. Deklaracija promenljivih. Inicijalizacija promenljivih. Deklaracija i inicijalizacija promenljivih

Java IMI PMF KG OOP 09 AKM. Izuzeci

/*#include <iostream> // Prvi zadatak sa integralnomg ispita

Vidljivost TipPovratneVrednosti ImeFunkcije (NizParametara) { TeloFunkcije }

Programski jezik JAVA PREDAVANJE

Veverica (za ocene >=3)

Java IMI PMF KG OOP 09 AKM. Objekti i klase

Informacioni sistemi i baze podataka

for i:=2 to n do if glasovi[i]>max then begin max:=glasovi[i]; k:=i {*promenljiva k ce cuvati indeks takmicara sa najvise glasova *} end;

I PISMENI ZADATAK III6 I GRUPA IME I PREZIME

public static void main(string []args) { System.out.println("Hello World"); /* prints Hello World */

4/29/03 Doc 25 C# Arrays, Indexers & Exceptions slide # 1

12. Uskladištene procedure (Stored Procedures)

Java. Ugnježdeni tipovi IMI PMF KG OOP 09 AKM. najveći deo teksta je preuzet sa slajdova Prof. Dragana Milićeva (ETF Bg) namenjenih pedmetu OOP2

Prirejanje in preverjanje tipov

Informatika Uvod u C#,.NET Framework i Visual Studio... nastavak...

Sberbank Business Online na Mozilla FireFox

Osnove programskog jezika C#

Kodiranje GUI aplikacija u Visual C#

VDSL modem Zyxel VMG1312-B10A/B30A

Tema 8: Koncepti i teorije relevantne za donošenje odluka (VEŽBE)

Java i Internet programiranje

KLASIFIKACIJA JELENA JOVANOVIĆ. Web:

Sveučilište u Zagrebu Fakultet strojarstva i brodogradnje. WEB programiranje HTML & CSS

RDF, RDFS i JSON-LD. NIKOLA MILIKIĆ URL: nikola.milikic.info

PVC Eco. Eco Prozori i Balkonska Vrata Bela Boja Dezeni drveta su 40% skuplji

Numeričke metode i praktikum

DETERMINATION OF THE CHARACTERISTIC PARAMETERS IN THE GENERAL COLLINEAR SPACES IN THE GENERAL CASE UDC (045)=20

Dežurni nastavnik: Kolokvijum traje 1.5 sat, prvih sat vremena nije dozvoljeno napuštanje kolokvijuma. Upotreba literature nije dozvoljena.

Nasleđivanje i izvedene klase u jeziku C++

Java Server Pages. 31-Dec-12

Visoka tehnička škola Niš

Sadržaj. Verzija 03/2017 Primjenjuje se od 20. novembra godine

Jezik Baze Podataka SQL. Jennifer Widom

Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.

Deo J. VBA Objects, Properties, Methods, Events,... PROJEKTOVANJE KLASNIH MODULA... Objekti Svojstva. Metode. Dogadjaji KLASE.

PVC Eco. Eco Prozori i Balkonska Vrata Bela Boja Dezeni drveta su 40% skuplji

Cjenovnik usluga informacionog društva

C++ minitutorial. Osnovni elementi i koncepti programskog jezika C++ uz primere

Windows Server 2012, VDI Licenciranje najprodavanijeg servera, što je novo, VDI licenciranje. Office 2013 / Office 365

Objektno orijentisano programiranje

Objektno Orijentisano Programiranje - C++

Kada se pokrene forma da bude plave boje. Dugme Crtaj krugove da iscrtava slučajan broj N krugova istog poluprečnika r (1/4 visine forme) čiji su

Uvod u JavaScript. Srđan Pantić mart godine

Marko Milošević.

Objektno orijentisano programiranje. Aleksandra Klašnja-Milićević Marko Marković

Univerzitet u Nišu Građevinsko-arhitektonski fakultet. 4. Ciklična algoritamska struktura 5. Jednodimenzionalno polje.

Osnovne strukture podataka

Lekcija 4. Java programiranje sa bazama podataka. dr Svetlana Cvetanović

Editovanje registra u Windowsu

VEŽBA 5 do while petlja, switch case

Oracle Proprietary Joins Za upite nad više od jedne tabele korišćenjem Oracle proprietary sintakse koristiti join uslov u WHERE izrazu:

Besplatni softverski alati

RIP v2. Mr Nenad Krajnović Katedra za telekomunikacije

For. 1) program ispis; {ispisuje brojeve od 1 do 5 jedan ispod drugog} uses wincrt; var s,i:integer; begin for i:=1 to 5do writeln(i); end.

Računarski praktikum 4

Internet programiranje

Objektno orijentisano programiranje 2. Grafički korisnički interfejs

Programski jezici. leto

Transcription:

Osnove programskog jezika C# Čas 5. Delegati, događaji i interfejsi

DELEGATI

Bezbedni pokazivači na funkcije Jer garantuju vrednost deklarisanog tipa. Prevodilac prijavljuje grešku ako pokušate da povežete funkciju koja ne odgovara deklarisanom tipu delegata. public delegate <tip> Metoda (<parametri>)

Rad sa različitim metodama

Kreiranje vrednosti

Višeznačni delegati

Event posebna promenljiva tipa delegata Objekat koristi događaj da bi obavestio drugi objekat da se nešto desilo. Događaji su objekti tipa delegata: public event imedelegata imedogađaja Tip događaja

Primer i pitanja Pritiskom na dugme form2 otvara se forma2 sa samo jednom labelom. Pritiskom na dugme boje menja se boja forme. Koristeći delegate i događaje omogućiti da labela sadrži RGB komponente boje koja je na glavnoj formi.

Zadatak za vežbanje: Napisati aplikaciju koja može da otvori više identičnih formi sa jedne roditeljske. Sve novootvorene forme imaju jedno polje za unos teksta (textbox). Roditeljsak forma ima jedno dugme za otvaranje forme i onoliko labela koliko ima otvorenih formi iz nje. U svakoj labeli treba da bude naziv novootvorene forme i tekst u textbox-u te formme. Problem rešiti koristeći događaje.

IZUZECI. BLOK try, catch, finally

System.Exception

Izbacivanje izuzetaka

HIJERARHIJA

BLOK finally Blok koda koji će uvek biti izvršen bez obzira na to da li u ispitnom bloku nastaje izuzetak ili ne. finally blok će se uvek izvršiti.

Random Predstavlja generator pseudo-slučajnih brojeva. Konstruktori: Random (Int32) Random () Initializes a new instance of the Random class, using a time-dependent default seed value.

Generisanje slučajnih celobrojnih vrednosti Random.Next () Returns a nonnegative random number. Random.Next (Int32) Returns a nonnegative random number less than the specified maximum. Random.Next (Int32, Int32) Returns a random number within a specified range.

Generisanje slučajnih vrednosti od 0.0 do 1.0 public virtual double NextDouble () A double-precision floating point number greater than or equal to 0.0, and less than 1.0.

Rezultati testa FixedSeedRandoms(123); FixedSeedRandoms(123); FixedSeedRandoms(456); FixedSeedRandoms(456); Random numbers from a Random object with seed = 123: 2114319875 1949518561 1596751841 1742987178 1586516133 103755708 0.01700087 0.14935942 0.19470390 0.63008947 0.90976122 0.49519146 Random numbers from a Random object with seed = 123: 2114319875 1949518561 1596751841 1742987178 1586516133 103755708 0.01700087 0.14935942 0.19470390 0.63008947 0.90976122 0.49519146 Random numbers from a Random object with seed = 456: 2044805024 1323311594 1087799997 1907260840 179380355 120870348 0.21988117 0.21026556 0.39236514 0.42420498 0.24102703 0.47310170 Random numbers from a Random object with seed = 456: 2044805024 1323311594 1087799997 1907260840 179380355 120870348 0.21988117 0.21026556 0.39236514 0.42420498 0.24102703 0.47310170

Zadatak za razmišljanje Koristeći random generator osmisliti i realizovati zaštitni koder i dekoder za snimanje/prenos podataka.

PRIMER RandomObjectDemo.cs

Interfejsi Sličan klasi ali,... Njegova jedina svrha je da deklariše skup metoda a ne da ih realizuje. Interfejsi su dakle apstraktne klase koje sadrže samo potpuno virtuelne metode. Ne sadrži polja! Pristup je javan public. Ako sadrži svojstvo klasa mora realizovati bar jednu od metoda svojstva get ili set

Definisanje ponašanja je zadatak klasa (struktura) koje nasleđuju interfejs.

Interfejsi

Korišćenje interfejsa

Još o nizovima na drugi način Deklarišući niz, pravite novi tip podataka izveden iz klase System.Array.

System.Array Apstraktna klasa i ne možete da pravite objekte ove klase osim......koristeći statičku metodu CreateInstance()

Pretraživanje niza - IndexOf Array.IndexOf (Array, Object) Searches for the specified object and returns the index of the first occurrence within the entire one-dimensional Array. Array.IndexOf (Array, Object, Int32) Searches for the specified object and returns the index of the first occurrence within the range of elements in the onedimensional Array that extends from the specified index to the last element. Array.IndexOf (Array, Object, Int32, Int32) Searches for the specified object and returns the index of the first occurrence within the range of elements in the onedimensional Array that starts at the specified index and contains the specified number of elements. Array.IndexOf (T[], T) Searches for the specified object and returns the index of the first occurrence within the entire Array. Array.IndexOf (T[], T, Int32) Searches for the specified object and returns the index of the first occurrence within the range of elements in the Array that extends from the specified index to the last element. Array.IndexOf (T[], T, Int32, Int32) Searches for the specified object and returns the index of the first occurrence within the range of elements in the Array that starts at the specified index and contains the specified number of elements.

Pretraživanje niza - LastIndexOf Array.LastIndexOf (Array, Object) Searches for the specified object and returns the index of the last occurrence within the entire one-dimensional Array. Array.LastIndexOf (Array, Object, Int32) Searches for the specified object and returns the index of the last occurrence within the range of elements in the onedimensional Array that extends from the first element to the specified index. Array.LastIndexOf (Array, Object, Int32, Int32) Searches for the specified object and returns the index of the last occurrence within the range of elements in the one-dimensional Array that contains the specified number of elements and ends at the specified index.. Array.LastIndexOf (T[], T) Searches for the specified object and returns the index of the last occurrence within the entire Array. Array.LastIndexOf (T[], T, Int32) Searches for the specified object and returns the index of the last occurrence within the range of elements in the Array that extends from the first element to the specified index. Array.LastIndexOf (T[], T, Int32, Int32) Searches for the specified object and returns the index of the last occurrence within the range of elements in the Array that contains the specified number of elements and ends at the specified index.

Sortiranje niza Array.Sort (Array) Sorts the elements in an entire one-dimensional Array using the IComparable implementation of each element of the Array. Array.Sort (Array, Array) Sorts a pair of one-dimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the IComparable implementation of each key. Array.Sort (Array, IComparer) Sorts the elements in a one-dimensional Array using the specified IComparer. Array.Sort (Array, Array, IComparer) Sorts a pair of one-dimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the specified IComparer. Array.Sort (Array, Int32, Int32) Sorts the elements in a range of elements in a one-dimensional Array using the IComparable implementation of each element of the Array. Array.Sort (Array, Array, Int32, Int32) Sorts a range of elements in a pair of one-dimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the IComparable implementation of each key. Array.Sort (Array, Int32, Int32, IComparer) Sorts the elements in a range of elements in a one-dimensional Array using the specified IComparer. Array.Sort (Array, Array, Int32, Int32, IComparer) Sorts a range of elements in a pair of onedimensional Array objects (one contains the keys and the other contains the corresponding items) based on the keys in the first Array using the specified IComparer.

PRIMER SamplesArray.cs

Nema više......za danas.