Parallel Systems Introductionparallel.vub.ac.be/education/java/theorie/java HOC 3 - 2017.pdf · 4....
Transcript of Parallel Systems Introductionparallel.vub.ac.be/education/java/theorie/java HOC 3 - 2017.pdf · 4....
Informatica 2e semester HOC 3
Informatica
Les 3
Elektronica ndash Overschrijven -GUI
Jan Lemeire
Informatica 2e semester
februari ndash mei 2017
Vandaag1 Bibliotheekklassen Set amp Map
2 Interfaces
3 Oefening
4 Overerving en overschrijven
5 GUI
6 Deel III hoofdstuk 2
7 Alan Turing
124 Verzameling
Set
Jan Lemeire 4Pag 72
De Set
Een wiskundige verzameling dus
In Java gedefinieerd als interface
Definitie van documentatie
ldquoA collection that contains no duplicate elements More formally
sets contain no pair of elements e1 and e2 such that e1equals(e2)
and at most one null elementrdquo
Informatica 2e semester HOC 3
p 31
Method Summary
booleanadd(E e)
Adds the specified element to this set if it is not already present
booleanaddAll(Collectionlt extends Egt c)
Adds all of the elements in the specified collection to this set if theyre not already
present (optional operation)
voidclear()
Removes all of the elements from this set
booleancontains(Object o)
Returns true if this set contains the specified element
booleancontainsAll(Collectionltgt c)
Returns true if this set contains all of the elements of the specified collection
booleanequals(Object o)
Compares the specified object with this set for equality
booleanisEmpty()
Returns true if this set contains no elements
booleanremove(Object o)
Removes the specified element from this set if it is present (optional operation)
booleanremoveAll(Collectionltgt c)
Removes from this set all of its elements that are contained in the specified collection
booleanretainAll(Collectionltgt c)
Retains only the elements in this set that are contained in the specified collection
intsize()
Returns the number of elements in this set (its cardinality)Informatica 2e semester HOC 3
Jan Lemeire 6Pag 72
Bewerkingen
bewerking methode
Unie a U b AddAll()
Doorsnede a cap b RetainAll()
Verschil a b RemoveAll()
Symmetrische
verschil
(a b) U (b a) Combinatie van
bovenstaande
Informatica 2e semester HOC 3
Interfaces
public interface SetltEgt extends CollectionltEgt
int size()boolean isEmpty()boolean contains(Object o)IteratorltEgt iterator()Object[] toArray()ltTgt T[] toArray(T[] a)boolean add(E e)boolean remove(Object o)boolean containsAll(Collectionltgt c)boolean addAll(Collectionlt extends Egt c)boolean retainAll(Collectionltgt c)boolean removeAll(Collectionltgt c)void clear()boolean equals(Object o)int hashCode()
Setjava
Jan Lemeire 9Pag 72
Interfaces
Alle methodes zijn abstract enkel header geen implementatie
Klasse die interface implementeert moet alle methodes implementeren
Informatica 2e semester HOC 3
p 5
Filosofie
een interface definieert hoe je met een object communiceert
Je hoeft de implementatie niet te kennen
Inwisselbare implementatie efficieumlntste implementatie hangt af van situatie
p 7Pijlers van object-georieumlnteerde
programmeertalen
Jan Lemeire 11Pag 72
Set Object implementatie
Implementaties voldoen aan het ldquoSet-kontraktrdquo
Gebruik TreeSet en HashSetKomen we op terug in hoofdstuk 8
Informatica 2e semester HOC 3
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Vandaag1 Bibliotheekklassen Set amp Map
2 Interfaces
3 Oefening
4 Overerving en overschrijven
5 GUI
6 Deel III hoofdstuk 2
7 Alan Turing
124 Verzameling
Set
Jan Lemeire 4Pag 72
De Set
Een wiskundige verzameling dus
In Java gedefinieerd als interface
Definitie van documentatie
ldquoA collection that contains no duplicate elements More formally
sets contain no pair of elements e1 and e2 such that e1equals(e2)
and at most one null elementrdquo
Informatica 2e semester HOC 3
p 31
Method Summary
booleanadd(E e)
Adds the specified element to this set if it is not already present
booleanaddAll(Collectionlt extends Egt c)
Adds all of the elements in the specified collection to this set if theyre not already
present (optional operation)
voidclear()
Removes all of the elements from this set
booleancontains(Object o)
Returns true if this set contains the specified element
booleancontainsAll(Collectionltgt c)
Returns true if this set contains all of the elements of the specified collection
booleanequals(Object o)
Compares the specified object with this set for equality
booleanisEmpty()
Returns true if this set contains no elements
booleanremove(Object o)
Removes the specified element from this set if it is present (optional operation)
booleanremoveAll(Collectionltgt c)
Removes from this set all of its elements that are contained in the specified collection
booleanretainAll(Collectionltgt c)
Retains only the elements in this set that are contained in the specified collection
intsize()
Returns the number of elements in this set (its cardinality)Informatica 2e semester HOC 3
Jan Lemeire 6Pag 72
Bewerkingen
bewerking methode
Unie a U b AddAll()
Doorsnede a cap b RetainAll()
Verschil a b RemoveAll()
Symmetrische
verschil
(a b) U (b a) Combinatie van
bovenstaande
Informatica 2e semester HOC 3
Interfaces
public interface SetltEgt extends CollectionltEgt
int size()boolean isEmpty()boolean contains(Object o)IteratorltEgt iterator()Object[] toArray()ltTgt T[] toArray(T[] a)boolean add(E e)boolean remove(Object o)boolean containsAll(Collectionltgt c)boolean addAll(Collectionlt extends Egt c)boolean retainAll(Collectionltgt c)boolean removeAll(Collectionltgt c)void clear()boolean equals(Object o)int hashCode()
Setjava
Jan Lemeire 9Pag 72
Interfaces
Alle methodes zijn abstract enkel header geen implementatie
Klasse die interface implementeert moet alle methodes implementeren
Informatica 2e semester HOC 3
p 5
Filosofie
een interface definieert hoe je met een object communiceert
Je hoeft de implementatie niet te kennen
Inwisselbare implementatie efficieumlntste implementatie hangt af van situatie
p 7Pijlers van object-georieumlnteerde
programmeertalen
Jan Lemeire 11Pag 72
Set Object implementatie
Implementaties voldoen aan het ldquoSet-kontraktrdquo
Gebruik TreeSet en HashSetKomen we op terug in hoofdstuk 8
Informatica 2e semester HOC 3
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
124 Verzameling
Set
Jan Lemeire 4Pag 72
De Set
Een wiskundige verzameling dus
In Java gedefinieerd als interface
Definitie van documentatie
ldquoA collection that contains no duplicate elements More formally
sets contain no pair of elements e1 and e2 such that e1equals(e2)
and at most one null elementrdquo
Informatica 2e semester HOC 3
p 31
Method Summary
booleanadd(E e)
Adds the specified element to this set if it is not already present
booleanaddAll(Collectionlt extends Egt c)
Adds all of the elements in the specified collection to this set if theyre not already
present (optional operation)
voidclear()
Removes all of the elements from this set
booleancontains(Object o)
Returns true if this set contains the specified element
booleancontainsAll(Collectionltgt c)
Returns true if this set contains all of the elements of the specified collection
booleanequals(Object o)
Compares the specified object with this set for equality
booleanisEmpty()
Returns true if this set contains no elements
booleanremove(Object o)
Removes the specified element from this set if it is present (optional operation)
booleanremoveAll(Collectionltgt c)
Removes from this set all of its elements that are contained in the specified collection
booleanretainAll(Collectionltgt c)
Retains only the elements in this set that are contained in the specified collection
intsize()
Returns the number of elements in this set (its cardinality)Informatica 2e semester HOC 3
Jan Lemeire 6Pag 72
Bewerkingen
bewerking methode
Unie a U b AddAll()
Doorsnede a cap b RetainAll()
Verschil a b RemoveAll()
Symmetrische
verschil
(a b) U (b a) Combinatie van
bovenstaande
Informatica 2e semester HOC 3
Interfaces
public interface SetltEgt extends CollectionltEgt
int size()boolean isEmpty()boolean contains(Object o)IteratorltEgt iterator()Object[] toArray()ltTgt T[] toArray(T[] a)boolean add(E e)boolean remove(Object o)boolean containsAll(Collectionltgt c)boolean addAll(Collectionlt extends Egt c)boolean retainAll(Collectionltgt c)boolean removeAll(Collectionltgt c)void clear()boolean equals(Object o)int hashCode()
Setjava
Jan Lemeire 9Pag 72
Interfaces
Alle methodes zijn abstract enkel header geen implementatie
Klasse die interface implementeert moet alle methodes implementeren
Informatica 2e semester HOC 3
p 5
Filosofie
een interface definieert hoe je met een object communiceert
Je hoeft de implementatie niet te kennen
Inwisselbare implementatie efficieumlntste implementatie hangt af van situatie
p 7Pijlers van object-georieumlnteerde
programmeertalen
Jan Lemeire 11Pag 72
Set Object implementatie
Implementaties voldoen aan het ldquoSet-kontraktrdquo
Gebruik TreeSet en HashSetKomen we op terug in hoofdstuk 8
Informatica 2e semester HOC 3
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 4Pag 72
De Set
Een wiskundige verzameling dus
In Java gedefinieerd als interface
Definitie van documentatie
ldquoA collection that contains no duplicate elements More formally
sets contain no pair of elements e1 and e2 such that e1equals(e2)
and at most one null elementrdquo
Informatica 2e semester HOC 3
p 31
Method Summary
booleanadd(E e)
Adds the specified element to this set if it is not already present
booleanaddAll(Collectionlt extends Egt c)
Adds all of the elements in the specified collection to this set if theyre not already
present (optional operation)
voidclear()
Removes all of the elements from this set
booleancontains(Object o)
Returns true if this set contains the specified element
booleancontainsAll(Collectionltgt c)
Returns true if this set contains all of the elements of the specified collection
booleanequals(Object o)
Compares the specified object with this set for equality
booleanisEmpty()
Returns true if this set contains no elements
booleanremove(Object o)
Removes the specified element from this set if it is present (optional operation)
booleanremoveAll(Collectionltgt c)
Removes from this set all of its elements that are contained in the specified collection
booleanretainAll(Collectionltgt c)
Retains only the elements in this set that are contained in the specified collection
intsize()
Returns the number of elements in this set (its cardinality)Informatica 2e semester HOC 3
Jan Lemeire 6Pag 72
Bewerkingen
bewerking methode
Unie a U b AddAll()
Doorsnede a cap b RetainAll()
Verschil a b RemoveAll()
Symmetrische
verschil
(a b) U (b a) Combinatie van
bovenstaande
Informatica 2e semester HOC 3
Interfaces
public interface SetltEgt extends CollectionltEgt
int size()boolean isEmpty()boolean contains(Object o)IteratorltEgt iterator()Object[] toArray()ltTgt T[] toArray(T[] a)boolean add(E e)boolean remove(Object o)boolean containsAll(Collectionltgt c)boolean addAll(Collectionlt extends Egt c)boolean retainAll(Collectionltgt c)boolean removeAll(Collectionltgt c)void clear()boolean equals(Object o)int hashCode()
Setjava
Jan Lemeire 9Pag 72
Interfaces
Alle methodes zijn abstract enkel header geen implementatie
Klasse die interface implementeert moet alle methodes implementeren
Informatica 2e semester HOC 3
p 5
Filosofie
een interface definieert hoe je met een object communiceert
Je hoeft de implementatie niet te kennen
Inwisselbare implementatie efficieumlntste implementatie hangt af van situatie
p 7Pijlers van object-georieumlnteerde
programmeertalen
Jan Lemeire 11Pag 72
Set Object implementatie
Implementaties voldoen aan het ldquoSet-kontraktrdquo
Gebruik TreeSet en HashSetKomen we op terug in hoofdstuk 8
Informatica 2e semester HOC 3
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Method Summary
booleanadd(E e)
Adds the specified element to this set if it is not already present
booleanaddAll(Collectionlt extends Egt c)
Adds all of the elements in the specified collection to this set if theyre not already
present (optional operation)
voidclear()
Removes all of the elements from this set
booleancontains(Object o)
Returns true if this set contains the specified element
booleancontainsAll(Collectionltgt c)
Returns true if this set contains all of the elements of the specified collection
booleanequals(Object o)
Compares the specified object with this set for equality
booleanisEmpty()
Returns true if this set contains no elements
booleanremove(Object o)
Removes the specified element from this set if it is present (optional operation)
booleanremoveAll(Collectionltgt c)
Removes from this set all of its elements that are contained in the specified collection
booleanretainAll(Collectionltgt c)
Retains only the elements in this set that are contained in the specified collection
intsize()
Returns the number of elements in this set (its cardinality)Informatica 2e semester HOC 3
Jan Lemeire 6Pag 72
Bewerkingen
bewerking methode
Unie a U b AddAll()
Doorsnede a cap b RetainAll()
Verschil a b RemoveAll()
Symmetrische
verschil
(a b) U (b a) Combinatie van
bovenstaande
Informatica 2e semester HOC 3
Interfaces
public interface SetltEgt extends CollectionltEgt
int size()boolean isEmpty()boolean contains(Object o)IteratorltEgt iterator()Object[] toArray()ltTgt T[] toArray(T[] a)boolean add(E e)boolean remove(Object o)boolean containsAll(Collectionltgt c)boolean addAll(Collectionlt extends Egt c)boolean retainAll(Collectionltgt c)boolean removeAll(Collectionltgt c)void clear()boolean equals(Object o)int hashCode()
Setjava
Jan Lemeire 9Pag 72
Interfaces
Alle methodes zijn abstract enkel header geen implementatie
Klasse die interface implementeert moet alle methodes implementeren
Informatica 2e semester HOC 3
p 5
Filosofie
een interface definieert hoe je met een object communiceert
Je hoeft de implementatie niet te kennen
Inwisselbare implementatie efficieumlntste implementatie hangt af van situatie
p 7Pijlers van object-georieumlnteerde
programmeertalen
Jan Lemeire 11Pag 72
Set Object implementatie
Implementaties voldoen aan het ldquoSet-kontraktrdquo
Gebruik TreeSet en HashSetKomen we op terug in hoofdstuk 8
Informatica 2e semester HOC 3
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 6Pag 72
Bewerkingen
bewerking methode
Unie a U b AddAll()
Doorsnede a cap b RetainAll()
Verschil a b RemoveAll()
Symmetrische
verschil
(a b) U (b a) Combinatie van
bovenstaande
Informatica 2e semester HOC 3
Interfaces
public interface SetltEgt extends CollectionltEgt
int size()boolean isEmpty()boolean contains(Object o)IteratorltEgt iterator()Object[] toArray()ltTgt T[] toArray(T[] a)boolean add(E e)boolean remove(Object o)boolean containsAll(Collectionltgt c)boolean addAll(Collectionlt extends Egt c)boolean retainAll(Collectionltgt c)boolean removeAll(Collectionltgt c)void clear()boolean equals(Object o)int hashCode()
Setjava
Jan Lemeire 9Pag 72
Interfaces
Alle methodes zijn abstract enkel header geen implementatie
Klasse die interface implementeert moet alle methodes implementeren
Informatica 2e semester HOC 3
p 5
Filosofie
een interface definieert hoe je met een object communiceert
Je hoeft de implementatie niet te kennen
Inwisselbare implementatie efficieumlntste implementatie hangt af van situatie
p 7Pijlers van object-georieumlnteerde
programmeertalen
Jan Lemeire 11Pag 72
Set Object implementatie
Implementaties voldoen aan het ldquoSet-kontraktrdquo
Gebruik TreeSet en HashSetKomen we op terug in hoofdstuk 8
Informatica 2e semester HOC 3
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Interfaces
public interface SetltEgt extends CollectionltEgt
int size()boolean isEmpty()boolean contains(Object o)IteratorltEgt iterator()Object[] toArray()ltTgt T[] toArray(T[] a)boolean add(E e)boolean remove(Object o)boolean containsAll(Collectionltgt c)boolean addAll(Collectionlt extends Egt c)boolean retainAll(Collectionltgt c)boolean removeAll(Collectionltgt c)void clear()boolean equals(Object o)int hashCode()
Setjava
Jan Lemeire 9Pag 72
Interfaces
Alle methodes zijn abstract enkel header geen implementatie
Klasse die interface implementeert moet alle methodes implementeren
Informatica 2e semester HOC 3
p 5
Filosofie
een interface definieert hoe je met een object communiceert
Je hoeft de implementatie niet te kennen
Inwisselbare implementatie efficieumlntste implementatie hangt af van situatie
p 7Pijlers van object-georieumlnteerde
programmeertalen
Jan Lemeire 11Pag 72
Set Object implementatie
Implementaties voldoen aan het ldquoSet-kontraktrdquo
Gebruik TreeSet en HashSetKomen we op terug in hoofdstuk 8
Informatica 2e semester HOC 3
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
public interface SetltEgt extends CollectionltEgt
int size()boolean isEmpty()boolean contains(Object o)IteratorltEgt iterator()Object[] toArray()ltTgt T[] toArray(T[] a)boolean add(E e)boolean remove(Object o)boolean containsAll(Collectionltgt c)boolean addAll(Collectionlt extends Egt c)boolean retainAll(Collectionltgt c)boolean removeAll(Collectionltgt c)void clear()boolean equals(Object o)int hashCode()
Setjava
Jan Lemeire 9Pag 72
Interfaces
Alle methodes zijn abstract enkel header geen implementatie
Klasse die interface implementeert moet alle methodes implementeren
Informatica 2e semester HOC 3
p 5
Filosofie
een interface definieert hoe je met een object communiceert
Je hoeft de implementatie niet te kennen
Inwisselbare implementatie efficieumlntste implementatie hangt af van situatie
p 7Pijlers van object-georieumlnteerde
programmeertalen
Jan Lemeire 11Pag 72
Set Object implementatie
Implementaties voldoen aan het ldquoSet-kontraktrdquo
Gebruik TreeSet en HashSetKomen we op terug in hoofdstuk 8
Informatica 2e semester HOC 3
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 9Pag 72
Interfaces
Alle methodes zijn abstract enkel header geen implementatie
Klasse die interface implementeert moet alle methodes implementeren
Informatica 2e semester HOC 3
p 5
Filosofie
een interface definieert hoe je met een object communiceert
Je hoeft de implementatie niet te kennen
Inwisselbare implementatie efficieumlntste implementatie hangt af van situatie
p 7Pijlers van object-georieumlnteerde
programmeertalen
Jan Lemeire 11Pag 72
Set Object implementatie
Implementaties voldoen aan het ldquoSet-kontraktrdquo
Gebruik TreeSet en HashSetKomen we op terug in hoofdstuk 8
Informatica 2e semester HOC 3
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
p 7Pijlers van object-georieumlnteerde
programmeertalen
Jan Lemeire 11Pag 72
Set Object implementatie
Implementaties voldoen aan het ldquoSet-kontraktrdquo
Gebruik TreeSet en HashSetKomen we op terug in hoofdstuk 8
Informatica 2e semester HOC 3
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 11Pag 72
Set Object implementatie
Implementaties voldoen aan het ldquoSet-kontraktrdquo
Gebruik TreeSet en HashSetKomen we op terug in hoofdstuk 8
Informatica 2e semester HOC 3
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 12Pag 72
public static void main(String[] args)
Systemoutprint(Geef range )
Scanner scanner = new Scanner(Systemin)
int N = scannernextInt()
SetltIntegergt getallen = new HashSetltIntegergt()
for(int i=2iltNi++) vanaf 2
getallenadd(i)
de zeef van Erathostenes
for(int i=2iltNi++)
if (getallencontains(i))
int m = i 2
while(m lt N)
getallenremove(m)
m = m + i
Systemoutprint(Er zijn +getallensize()+
priemgetallen kleiner dan +N+ +getallen)
Informatica 2e semester HOC 3
p 33
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
125 Mappen
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 14Pag 72
Mappen of dictionaries
Linken object van type A aan objecten van type BOpzoeken gebeurt op A-objecten dus A best gesorteerd
Voorbeeld
Informatica 2e semester HOC 3
Ida Jennifer Oprolbare brug
Laurent Maarten Ultragrabber
Manuka Stani Moving Tower Ahmedabad
Mitichashvili Tornike piramide
Nguyen Kim trap Villa Savoye
Pelicaen Erik achthoekstructuur
Perez Sotomayor Lucia Origami
student projectkey value
p 33
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 15Pag 72
Java map
Interface MapltKVgtMet Type Parameters
K - the type of keys maintained by this map
V - the type of mapped values
Informatica 2e semester HOC 3
MapltStudent Stringgt map
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Map methodesvoidclear()
Removes all of the mappings from this map (optional operation)
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value
SetltMapEntryltKV
gtgt
entrySet()
Returns a Set view of the mappings contained in this map
booleanequals(Object o)
Compares the specified object with this map for equality
Vget(Object key)
Returns the value to which the specified key is mapped or null if this map contains no
mapping for the key
inthashCode()
Returns the hash code value for this map
booleanisEmpty()
Returns true if this map contains no key-value mappings
SetltKgtkeySet()
Returns a Set view of the keys contained in this map
Vput(K key V value)
Associates the specified value with the specified key in this map (optional operation)
voidputAll(Maplt extends K extends Vgt m)
Copies all of the mappings from the specified map to this map (optional operation)
Vremove(Object key)
Removes the mapping for a key from this map if it is present (optional operation)
intsize()
Returns the number of key-value mappings in this map
CollectionltVgtvalues()
Informatica 2e semester HOC 3
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 17Pag 72
Implementaties van Java map
TreeMap en HashMapTree of Hashtabel (zien er later)
MapltString Stringgt map
map = new TreeMapltString Stringgt()
of
map = new HashMapltString Stringgt()
Cf TreeSet en HashSet implementaties van de Set interface
Informatica 2e semester HOC 3
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Klasse-oefening
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
p 63
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Gegeven de volgende klassen Trapezium Rechthoek Vierkant
1 Maak een object aan van elke klasse Kies je eigen waarden
voor de parameters
2 Duidt aan welke constructors worden opgeroepen en welke
superconstructors
3 Geef voor elk object de waarde van de attributen
4 Bereken de oppervlakte van de trapezium en print deze af
5 Voeg een methode toe aan Rechthoek die de oppervlakte
berekent
6 Maak van de rechthoek een subklasse van het trapezium Dan
zijn de attributen breedte en lengte in feite niet meer
nodig die mag je dus schrappen De oppervlaktemethode ook
7 Vierkant erft alle attributen over maar heeft er in feite
slechts 1 nodig Schrap de extends Rechthoek voeg het nodige
attribuut toe en de methode voor oppervlaktebrekening
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
126 Generics
TER INFO
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
13
Vriendenvoorbeeld
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 23Pag 72
Objecten
Informatica 2e semester HOC 3
p 36
attributen van
moederklasse
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 24Pag 72
Overerving
Informatica 2e semester HOC 3
p 39
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 25Pag 72Informatica 2e semester HOC 3
p 37-38
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 26Pag 72Informatica 2e semester HOC 3
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 27Pag 72
Ontkenner
Informatica 2e semester HOC 3
Maak van Elke een ontkenner
Overerving ndash Inheritance
met overschrijven van methode
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 28Pag 72
Javarsquos spelregels
Informatica 2e semester HOC 3
p 5
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 29Pag 72
Leugenaar
Informatica 2e semester HOC 3
Maak van Piet een leugenaar
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Waarom een burgerlijk ingenieur aanwerven
bull Werkkracht
bull Doorzettingsvermogen
bull Zelfdiscipline
bull Werkmethode
bull Analytisch denken
bull Probleemoplossend vermogen
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
14 Graphical User
Interface (GUI)
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 32Pag 72
GUI
GUI = Graphical User Interface
Gebruiken van de javaklassen van Swing
Online documentatie
Gebaseerd op de kracht van object-georieumlnteerde talen
Encapsulatie
Overerving (Inheritance)
Abstractiepolymorphismendash interfaces
Informatica 2e semester HOC 3
p 40
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 33Pag 72
GUI-componenten
Informatica 2e semester HOC 3
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 34Pag 72
Swingrsquos klassehieumlrarchie
Informatica 2e semester HOC 3
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Informatica 2e semester HOC 3
import javaxswing
public class MyPanel1 extends JPanel
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel1()inputVeld = new JTextField(20) groote veld ( symbolen)okKnop = new JButton(OK) inhoud knopjeoutputVeld = new JTextArea(130) dimensies veld (rijen
kolommen)
toevoegen van veldjes aan de GUIthisadd(new JLabel(Hoe heet je)) Jlabel tekst op je GUIthisadd(inputVeld)thisadd(okKnop)thisadd(outputVeld)
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
public static void main(String[] args) JFrame frame = new JFrame()framesetSize(400 100) dimensies van het vensterframesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE) zorgt dat
het programma afsluit bij het klikken op de X-knopframesetTitle(Voorbeeldvenster) titel van het vensterframesetLocation(100 100) positie van de linkerbovenhoek van
het venster op het bureaublad
JPanel hoofdpaneel = new MyPanel1() maak MyPanel1-object aanframeadd(hoofdpaneel) stop het in de Frame
framesetVisible(true) het venster wordt geactiveerd
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
MyPanel()
JTextField
JTextField(String text)
JTextField(int kolommen)
text
Beheert alle applicaties
in ons geval het JFrame-
object
Windows
JButton
JButton(String text)
JButton(String text Icon icon)
OK
text actionListeners
inputVeld okKnop OutputVeld
JTextArea
text
JTextArea(int rijen int kolommen)
components
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 38Pag 72
Events
Informatica 2e semester HOC 3
public class MyPanel2 extends JPanel implements ActionListener
GUI-componentenprivate JTextField inputVeldprivate JButton okKnopprivate JTextArea outputVeld
public MyPanel2()
hellip
okKnopaddActionListener(this) associatie ActionListener
Dit wordt uitgevoerd wanneer er op de knop gedrukt wordtpublic void actionPerformed(ActionEvent e)
outputVeldsetText(Hallo + inputVeldgetText() +
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 39Pag 72
Interface ActionListener
Informatica 2e semester HOC 3
interface ActionListener
public void actionPerformed(ActionEvent e)
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Voorbeeld 1
title
100
location size
components
JFrame
100 500 200
JFrame()
visible
JPanel
MyPanel
JPanel()
components
interface ActionListener
void actionPerformed(ActionEvent e)
Windows
Bepaal component op
positie (x y) en bericht
van event
Kliksignaal en beweging
cursorpositie
Cursorbeweging
positie
en kliks
muisklik
Event handling achter de schermen van windows
ActionEvent
gtKopieergt
command
ACTION_PERFORMED
parameters
oproepen
actionPerformed() van
alle actionListeners
met ActionEventvoid actionPerformed(ActionEvent e)
hellip
JButton
void addActionListener()
OK
text actionListeners
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 41Pag 72
Graphics
Informatica 2e semester HOC 3
public class MyPanel3 extends JPanel
public void paintComponent(Graphics g)
gsetColor(ColorGREEN)gfillOval(5050150150)gsetColor(ColorBLACK)gdrawLine(00250250)
public static void main(String[] args)
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Voorbeeld 1
title components
JFrame JPanel
MyPanel JTextField
JButton
components
Windows
Bepaal welke
componenten getekend
en hertekend moeten
worden
Graphics
Expliciet hertekenen
doe je door de repaint()
van je frame of panel op
te roepen
Deze geeft dan het
commando door aan
Windows
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
teken frame
zet titel
voor alle componenten i
components[i]paintComponent(g)
void paintComponent(Graphics g)
superpaintComponent(g)
gdrawOval(100 100 10 10)
void paintComponent(Graphics g)
void paintComponent(Graphics g)
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Method Summaryabstract void clearRect(int x int y int width int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface
void draw3DRect(int x int y int width int height boolean raised)Draws a 3-D highlighted outline of the specified rectangle
abstract void drawArc(int x int y int width int height int startAngle int arcAngle)Draws the outline of a circular or elliptical arc covering the specified rectangle
void drawChars(char[] data int offset int length int x int y)Draws the text given by the specified character array using this graphics contexts current font and color
abstract boolean drawImage(Image img int x int y ImageObserver observer)Draws as much of the specified image as is currently available
abstract void drawLine(int x1 int y1 int x2 int y2)Draws a line using the current color between the points (x1 y1) and (x2 y2) in this graphics contexts coordinate system
abstract void drawOval(int x int y int width int height)Draws the outline of an oval
abstract void drawPolygon(int[] xPoints int[] yPoints int nPoints)Draws a closed polygon defined by arrays of x and y coordinates
abstract void drawPolyline(int[] xPoints int[] yPoints int nPoints)Draws a sequence of connected lines defined by arrays of x and y coordinates
void drawRect(int x int y int width int height)Draws the outline of the specified rectangle
abstract void drawRoundRect(int x int y int width int height int arcWidth int arcHeight)Draws an outlined round-cornered rectangle using this graphics contexts current color
abstract void drawString(String str int x int y)
Graphics
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
144 Animaties en Timers
Oefeningen
EINDE BOEK I in de theorie
(wel nog 1 oefening)
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Leibnizrsquo droom
De ldquoCalculus ratiocinatorrdquo
Een logisch denkend apparaat
Informatica 2e semester HOC 3
1646 ndash 1716
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Go digital Go binary
Van analoog naardigitaalhellip
Informatica 2e semester HOC 3
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Binair rekenen
1 input =gt 1 outputMaar 1 niet-triviale functie NOT
2 inputs =gt 1 output
Genoeg voor een basis AND OR XOR NOT
Alle functies (met meer inputs) zijn samen testellen uit deze
0 1
0
1
24 = 16 mogelijkheden
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Informatica II les 2
0 1
0 0 0
1 0 0
0 1
0 0 1
1 0 1
0 1
0 1 1
1 1 1
0 1
0 1 0
1 1 0
0 1
0 1 1
1 0 0
0 1
0 0 0
1 1 1
0 1
0 0 1
1 1 0
0 1
0 1 0
1 0 1
0 1
0 0 1
1 1 1
0 1
0 1 0
1 0 0
0 1
0 0 0
1 0 1
0 1
0 1 1
1 1 0
0 1
0 0 1
1 0 0
0 1
0 1 0
1 1 1
0 1
0 0 0
1 1 0
0 1
0 1 1
1 0 1
triviaal exclusive or (xor)
or
and
2 inputs =gt 1 output 16 mogelijkheden
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
(1) Digitaal amp binair
(4) Hardware architectuur
(5) Efficieumlnt productieproces
(6) Computatietheorie amp Software
Electronica (2) lsquorelaisrsquo-schakeling
(3)geheugen
(7) Operating system
(8) Communicatie amp
internet
(9) Artificieumlle
intelligentie
Informatica deel III technologie historiek en economische aspecten
Waarmaken van Leibnizrsquos droom
(0) Het idee
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 50Pag 72
Hoofdstuk 2 De elektronische relais
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Hoe electrisch maken
1 Geleider
1 Weerstand
2 Spoel
3 Verbinden van componenten
2 Isolator (dielectric)
1 Condensator
2 Scheiden van componenten
Extra component nodighellip
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 52Pag 72
Nodig de relais
Electro-mechanisch
Informatica II les 3
Naast de geleider weerstand capaciteit en spoel hebben we een component nodig met de werking zoals de elektromechanische relais De relais zorgt ervoordat een signaal een ander signaal kan beiumlnvloedenHet inputsignaal bepaalt of de output lsquoaanrsquo of lsquouitrsquo is Met deze component kunnen we elektrische schakelingen maken die binair kunnen rekenen Gebaseerd op de elektromechanische relais bouwde de duitser Zuse een volledig werkende computer die gebruikt werd tijdens de tweede wereldoorlog
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 53Pag 72
Binair rekenen
Informatica II les 3
or
and A B C = A and B
C = A or B
A
B
Met deze componenten kan je alles berekenen
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Complexe functies
Algemeen van n inputs naar m outputs2-naar-m kan je ontbinden als m keer 2-naar-1
n-naar-1 kan je ontbinden door 2 bij 2 samen te nemen
ndash Bvb a b c d =gt x door a b =gt e c d =gt f en e f =gt x
Beide samen geeft n-naar-m
ndash is misschien wel niet het efficientste
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Som van bits
Som S van 2 bits A en B De carriage (C) geeft de bit voor de volgende orde
Rekening houdend met de carriage bit (Cin) van de vorige orde
Half adder
Full adder
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Som van getallen
Twee getallen (A en B) van 3 bits bij elkaar tellen (S)Ripple carry adder
Overflow bit
Zie httpparallelvubacbeeducationjavaappletshtml
Least-significant bits (bits van laagste orde)
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
WOII de duitsers
Een werkende electro-mechanischecomputer
Konrad Zuse
Door de mechanische componenten beperkt tot vijftien agrave
twintig operaties per seconde
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 59Pag 72
De Vacuuumlmbuis elektronische relais
Vrije elektronen in vacuuumlm
diode versterker
grid
inout
gloeilamp
De spanning (in) van het grid van de vacuuumlmbuis bepaalt de geleidbaarheid tussenanode en kathode Door een grote spanning op out te zetten zal een kleininputsignaal versterkt worden Een signaal met een klein vermogen wordt omgezetin een signaal met een groot vermogen
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Vacuuumlmbuizen
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 61Pag 72Informatica II les 3
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 62Pag 72
De eerste computer ENIAC
John Mauchly and John Eckert 1945
De ENIAC maakte gebruik van vacuuumlmbuizen voor het rekenen Deze zijn echterduur groot onhandig en gaan gemakkelijk stuk
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 63Pag 72
Van vacuuumlmbuis naar transistor
grid
inout
halfgeleider
Maar de echte doorbraak kwam met de uitvinding van de transistor 10 jaar () werd er in Bell Labs (van ATampT - American Telephone amp Telegraph Company) actiefgezocht naar een handige vervanger van de vacuuumlmbuis Het labo bestond uitpraktische technici theoretici (fysica wiskunde chemie) en creatieve geesten De eerste succesvolle toepassing was de draagbare transistorradio
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 64Pag 72
Transistor (MOSFET)
De spanning VG bepaalt de geleidbaarheid van de halfgeleider(semiconductor) tussen Source en Drain
Te gebruiken als versterker
Te gebruiken als relais voor binaire operaties
halfgeleider
halfgeleider
De halfgeleider gedraagt zich als een isolator als VG=0 en als geleider bij VGgt1V We hebben een elektronische relais
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Jan Lemeire 65Pag 72Informatica II les 4
transistors
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Informatica 2e semester HOC 3
Analoge electronica
Sommeren integreren afleiden
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Alan Turing
Deel III
Hoofdstuk 1
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Winston Churchill
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Bletchley Park
Op zoek naar cribs
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
De Enigmacode
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014
Colossus the first operational electronic computer
Alan Turing
1912-1954
Jan Lemeire 72Pag 72Informatica 2e semester HOC 3
Film 2014