(2.2) Hallo één klasse...met één methode...met acht opdrachten accolades begrenzen klasse en methode using Android.OS; using Android.App; using Android.Widget;

Slides:



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

Vervolg C Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1 Onderwerpen voor vandaag Dallas one-wire interface Opgave:
Vervolg C Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1 Onderwerpen voor vandaag functie definitions;.h files;
Onderwerpen voor vandaag
Je gebruikt will of going to als je het over de toekomst hebt. I will phone you tonight. Next week we will know the results.
W 2 L 1 sh 1 Assignments Read the ‘overzicht’ document! OnderwerpV2CCPP1 x y x = student nummer y = nummer.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 12 th -13 th Lecture Pavel Ježek.
Nov 2005 MSc Slide 1 - Another Example of a Structural Pattern Alternative way of adding Functionality to an existing class (alternative to a derived class)
Cosc 5/4730 Blackberry Drawing. Screen size With Blackberry devices, they have a known screen size in pixels. If you are programming for specific device.
Thursday, 16 April 2015 donderdag 16 april 2015 Click Klik.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
C#: Data Types Based on slides by Joe Hummel. 2 UCN Technology: Computer Science Content: “.NET is designed around the CTS, or Common Type System.
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Hoofdstuk 13 Object-georiënteerd ontwerp. Methode-aanroep: Type van parameters void paint(Graphics g) { g.drawRect( ); class Graphics { void drawRect(int.
Toepassing: schets-editor Canvas om op te tekenen Tools Controls Menu.
Array nDeclaratie nCreatie nOpvragen nWijzigen nLengte String [ ] a; a = new String[10]; ……a[5]…… a[5] = ……; …a.length… …is eigenlijk overbodig! ArrayList.
Wordpress Hoe doe je dat bij DSE Bloggen met. Log in op de homepage, klik in mijn account op Wordpress installeren.
Het leven als schipper is niet altijd Roze geur & manen schijn.
1 More on Classes Overview l Overloading l The this keyword l The toString method l The equals method.
2D Graphics: Part 1. Android Graphics Libraries 2D Graphics –custom 2D graphics library in packages android.graphics android.graphics.drawable android.graphics.drawable.shapes.
2D Graphics: Part 2.
Packages. Package A package is a set of related classes Syntax to put a class into a package: package ; public class { …} Two rules:  A package declaration.
1 Scroll Bars Providing Scrollbars. 2 Objectives You will be able to: Use Windows Graphics to display tabular information on a Windows form. Add graphics.
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Encapsulation, this reading: self-checks: #13-17 exercises:
Exercises on Basic OOP TCP1201: 2013/2014.  Problem: Design and build a computer hockey game.  Object: Hockey player  Attribute: Position, height,
Android Graphics Library. Color Android colors are represented with four numbers, one each for alpha, red, green, and blue (ARGB). Each component can.
Custom Widget 1 UNIT 26 로봇 SW 콘텐츠 교육원 조용수. 캔버스 public void drawColor(int color) 2 public class ControllerView extends View { public ControllerView(Context.
IAP C# and.NET 2011 Lecture 1: Basic Syntax Geza Kovacs.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
CSE 341 Lecture 26 OOP, prototypes, and inheritance slides created by Marty Stepp
WxHaskell Daan Leijen. Ok…. Dat lijkt me een goed plan. Denk je dat je zo iets dinsdag af kunt hebben en presenteren? Doaitse On donderdag, september.
1 9/6/05CS360 Windows Programming CS360 Windows Programming.
Class and Structure. 2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor.
Android Application Lifecycle and Menus
Custom Widget 2 UNIT 27 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Custom Widget –Canvas 를 이용하여 Custom Widget 을 만든다. 2.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
Xamarin Android Hands On. Hands-On: Xamarin Android Ziele – Kennenlernen von Xamarin Android – Native UI –
Value Types. 2 Objectives Discuss concept of value types –efficiency –memory management –value semantics –boxing –unboxing –simple types Introduce struct.
Paragraaf 3.2: De energie van de toekomst. 1 Herhaling vorige les 2 Energietransitie 3 Duurzaam en zuinige energie 4 Maken opdrachten 5 (Werken aan je.
Motivatie & Commitment – Een eerste stap naar slagen voor je examen statistiek
Lecture 3: Animation & Graphics
Sprite Sheets, Game States
Gameprogrammeren: Klassen en objecten in Painter
滑動版面 建國科技大學 資管系 饒瑞佶 2013/7 V1.
CS499 – Mobile Application Development
Android – Event Handling
2.7 Inheritance Types of inheritance
string versus array Klasse Type met speciale syntax Indexer -notatie
Voorbeeld-programma's
Module 5: Common Type System
COP 3331 Object Oriented Analysis and Design Chapter 5 – Classes and Inheritance Jean Muhammad.
(H9.1) CirkelKlikker ARRAY int x, y; [ ] int n=0;
Gameprogrammeren: Edit states
Gameprogrammeren: Menu’s in Penguin Pairs
Er zijn verschillende redenen waarom een ​​ laptop problemen zou kunnen hebben met het opladen. Bestudeer eerst het stopcontact, het snoer en de verbinding,
Android Programming Lecture 6
בניית מחלקות.
null, true, and false are also reserved.
البرمجة بلغة الفيجول بيسك ستوديو
البرمجة بلغة فيجول بيسك ستوديو
Conditional Statements
בניית מחלקות.
Chapter 8: Graphics, Animations, Sounds, and Gaming
Gameprogrammeren: Interactie in Penguin Pairs
Module 2 Variables, Assignment, and Data Types
Gameprogrammeren: Game states
Handout-4b More on Classes
Abstract Data Types Stacks CSCI 240
Lasalle-App Tecnología Móvil.
CIS 470 Mobile App Development
Presentation transcript:

(2.2) Hallo één klasse...met één methode...met acht opdrachten accolades begrenzen klasse en methode using Android.OS; using Android.App; using Android.Widget; using Android.Graphics; [ActivityAttribute(Label = "Hello", MainLauncher = true)] public class HalloApp : Activity { protected override void OnCreate(Bundle b) { base.OnCreate(b); TextView scherm; scherm = new TextView(this); scherm.Text = "Hallo!"; scherm.TextSize = 80; scherm.SetBackgroundColor(Color.Yellow); scherm.SetTextColor(Color.DarkBlue); this.SetContentView(scherm); }

(2.6) Klok AnalogClock wijzerklok; wijzerklok = new AnalogClock(this); wijzerklok.SetBackgroundColor(Color.Yellow); TextClock tekstklok; tekstklok = new TextClock(this); tekstklok.Format24Hour = "EEE HH:mm:ss"; tekstklok.TextSize = 50; TextView scherm; scherm = new TextView(this); scherm.Text = "Hallo!"; scherm.TextSize = 80; scherm.SetBackgroundColor(Color.Yellow); scherm.SetTextColor(Color.DarkBlue); this.SetContentView( scherm );

(2.6) Klok AnalogClock wijzerklok; wijzerklok = new AnalogClock(this); wijzerklok.SetBackgroundColor(Color.Yellow); TextClock tekstklok; tekstklok = new TextClock(this); tekstklok.Format24Hour = "EEE HH:mm:ss"; tekstklok.TextSize = 50; this.SetContentView( scherm ); LinearLayout stapel; stapel = new LinearLayout(this); stapel.Orientation = Orientation.Vertical; stapel stapel.AddView(wijzerklok); stapel.AddView(tekstklok);

(3.1) Teller Button public class KlikkerApp : Activity { protected override void OnCreate(Bundle b) { base.OnCreate(b); knop = new Button(this); knop.Text = "Klik hier!"; knop.TextSize = 40; SetContentView(knop); } public void klik(object o, EventArgs ea) { } knop.Click += klik; knop.Text = teller.ToString() + " keer geklikt"; teller = teller + 1; } teller = 0; Button knop;int teller;

(3.1) Teller public class KlikkerApp : Activity { } } teller = 0; Button knop;int teller; protected override void OnCreate(Bundle b) { base.OnCreate(b); knop = new Button(this); knop.Text = "Klik hier!"; knop.TextSize = 40; SetContentView(knop); } knop.Click += klik; properties van Button Event-property van Button public void klik(object o, EventArgs ea) { knop.Text = teller.ToString() + " keer geklikt"; Event-handler teller = teller + 1; …krijgt als waarde een…

(3.1) Teller Button public class KlikkerApp : Activity { protected override void OnCreate(Bundle b) { base.OnCreate(b); knop = new Button(this); knop.Text = "Klik hier!"; knop.TextSize = 40; knop.Click += klik; SetContentView(knop); } public void klik(object o, EventArgs ea) { } knop.Text = teller.ToString() + " keer geklikt"; teller = teller + 1; } teller = 0; Button knop;int teller;

(3.2) Mixer Button public class MixerApp : Activity { protected override void OnCreate(Bundle b) { base.OnCreate(b); knop = new Button(this); knop.Text = "Klik hier!"; knop.TextSize = 40; knop.Click += kies; SetContentView(knop); } public void kies(object o, EventArgs ea) { } } Button knop; SeekBar SeekBar rood, groen, blauw; rood = new SeekBar(this); rood.SetBackgroundColor(Color.Red); rood.ProgressChanged += schuif; public void schuif(object o, EventArgs ea) { } groen= new SeekBar(this); groen.SetBackgroundColor(Color.Green); groen.ProgressChanged += schuif; blauw= new SeekBar(this); blauw.SetBackgroundColor(Color.Blue); blauw.ProgressChanged += schuif; LinearLayout lay = …… SetContentView(lay);

(3.2) Mixer Button public void schuif(object o, EventArgs ea) { SeekBar int r, g, b; } r = rood.Progress; g = groen.Progress; b = blauw.Progress; SeekBar rood, groen, blauw; Button knop; knop.Text = "r:" + r + "g:" + g + "b:" + b; knop.SetBackgroundColor ( new Color(r, g, b) ); public void kies(object o, EventArgs ea) { } Random gen; gen = new Random(256); rood.Progress = gen.Next(); groen.Progress = gen.Next(); blauw.Progress = gen.Next();

(4.1) Maak je eigen View protected override void OnCreate(Bundle b) { base.OnCreate(b); TextView t; t = new TextView(this); this.SetContentView(t); AnalogClock a; a = new AnalogClock(this); this.SetContentView(a); MondiaanView m; m = new MondriaanView(this); this.SetContentView(m); } bestaat nog niet…

(4.1) Maak je eigen View public class MondriaanView : View { protected override void OnDraw(Canvas cv) { public MondriaanView(Context ct) { } } } cv. DrawLine(…); cv. DrawRect(…); cv. DrawCircle(….); this.SetBackgroundColor(Color.White); base.View(ct); : base(ct) base.OnDraw(cv);

(4.6) Maak je eigen Methodes public class MondriaanView : View { protected override void OnDraw(Canvas cv) { } } cv. DrawLine(…); cv. DrawRect(…); cv. DrawCircle(….); base.OnDraw(cv); this. TekenHuis(cv, …);

(4.6) Maak je eigen Methodes c.DrawRect ( …, verf); c.DrawLine ( …, verf); c.DrawLine ( …, verf); } x, y-br, x+br, y int tx = x+br/2; int ty = y–br–br/2; x, y-br, tx, ty tx, ty, x+br, y-br private void tekenHuis (Canvas c, … ) { Paint verf = new Paint(); int x, int y, int br) this. tekenHuis (c, …); this. tekenHuis (c, …); this. tekenHuis (c, …); } protected override void OnDraw(Canvas c) { (x,y)br (tx,ty) 20, 100, 40); 70, 100, 40); 120, 100, 60);

(3.1) Teller protected override void OnCreate(Bundle b) { base.OnCreate(b); class MijnAct : Activity } { knop = new Button(this); knop.Click += klik; this.SetContentView(knop); public void klik(object o, EventArgs ea) { } knop.Text = "1x geklikt"; } Button knop;

(6.1) Touch protected override void OnCreate(Bundle b) { base.OnCreate(b); class MijnAct : Activity } { scherm = new MijnView(this); knop.Click += klik; this.SetContentView(scherm); public void klik(object o, EventArgs ea) { } knop.Text = "1x geklikt"; } MijnView scherm;

(6.1) Touch protected override void OnCreate(Bundle b) { base.OnCreate(b); class MijnAct : Activity } { scherm = new MijnView(this); this.SetContentView(scherm); } MijnView scherm; } { protected override void OnDraw(Canvas c) { base.OnDraw(c); } public MijnView(Context c) : base(c) { } c.DrawLine(...); class MijnView : View scherm.Click += klik;

(6.1) Touch protected override void OnCreate(Bundle b) { base.OnCreate(b); class MijnAct : Activity } { scherm = new MijnView(this); this.SetContentView(scherm); } MijnView scherm; } { protected override void OnDraw(Canvas c) { base.OnDraw(c); } public MijnView(Context c) : base(c) { } c.DrawLine(...); class MijnView : View scherm.Touch += raakAan; public void raakAan(object o, EventArgs ea) { }

(6.1) Touch protected override void OnCreate(Bundle b) { base.OnCreate(b); class MijnAct : Activity } { scherm = new MijnView(this); this.SetContentView(scherm); } MijnView scherm; } { protected override void OnDraw(Canvas c) { base.OnDraw(c); } public MijnView(Context c) : base(c) { } c.DrawLine(...); class MijnView : View scherm.Touch += raakAan; public void raakAan(object o, EventArgs ea) { } this.Touch += raakAan; public void raakAan(object o, EventArgs ea) { }

(6.1) Touch protected override void OnCreate(Bundle b) { base.OnCreate(b); class MijnAct : Activity } { scherm = new MijnView(this); this.SetContentView(scherm); } MijnView scherm; } { protected override void OnDraw(Canvas c) { base.OnDraw(c); } public MijnView(Context c) : base(c) { } c.DrawLine(...); class MijnView : View this.Touch += raakAan; public void raakAan(object o, EventArgs ea) { }

(6.1) Touch } { protected override void OnDraw(Canvas c) { base.OnDraw(c); } public MijnView(Context c) : base(c) { this.Touch += raakAan; } class MijnView : View public void raakAan(object o, TouchEventArgs tea) { } } c.DrawCircle(x, y, 50, new Paint()); x = tea.Event.GetX(); y = tea.Event.GetY(); this.Invalidate(); float x, y;

(6.1) Bitmap } { protected override void OnDraw(Canvas c) { base.OnDraw(c); } public MijnView(Context c) : base(c) { this.Touch += raakAan; } class MijnView : View public void raakAan(object o, TouchEventArgs tea) { } } c.DrawBitmap(b, p.X, p.Y, new Paint()); x = tea.Event.GetX(); y = tea.Event.GetY(); this.Invalidate(); float x, y; PointF p; p = new PointF(x, y); if (p != null) b = BitmapFactory.DecodeResource (...Icon...); Bitmap b;

(6.2) Punten } { protected override void OnDraw(Canvas c) { base.OnDraw(c); } public MijnView(Context c) : base(c) { this.Touch += raakAan; } class MijnView : View public void raakAan(object o, TouchEventArgs tea) { } } c.DrawBitmap(b, p.X, p.Y, new Paint()); x = tea.Event.GetX(); y = tea.Event.GetY(); this.Invalidate(); float x, y; PointF p; p = new PointF(x, y); if (p != null) met bitmap b = BitmapFactory.DecodeResource (...Icon...); Bitmap b; List alles ;

(6.2) Punten } { protected override void OnDraw(Canvas c) { base.OnDraw(c); } public MijnView(Context c) : base(c) { this.Touch += raakAan; } class MijnView : View public void raakAan(object o, TouchEventArgs tea) { } } c.DrawBitmap(b, p.X, p.Y, new Paint()); x = tea.Event.GetX(); y = tea.Event.GetY(); this.Invalidate(); float x, y; PointF p; p = new PointF(x, y); if (p != null) met bitmap b = BitmapFactory.DecodeResource (...Icon...); Bitmap b; List alles ; alles.Add(p);

(6.2) Punten } { protected override void OnDraw(Canvas c) { base.OnDraw(c); } public MijnView(Context c) : base(c) { this.Touch += raakAan; } class MijnView : View public void raakAan(object o, TouchEventArgs tea) { } } c.DrawBitmap(b, p.X, p.Y, new Paint()); x = tea.Event.GetX(); y = tea.Event.GetY(); this.Invalidate(); float x, y; PointF p; p = new PointF(x, y); foreach( PointF p in alles) met bitmap b = BitmapFactory.DecodeResource (...Icon...); Bitmap b; List alles ; alles.Add(p);

(6.2) Punten } { protected override void OnDraw(Canvas c) { base.OnDraw(c); } public MijnView(Context c) : base(c) { this.Touch += raakAan; } class MijnView : View public void raakAan(object o, TouchEventArgs tea) { } } c.DrawBitmap(b, p.X, p.Y, new Paint()); x = tea.Event.GetX(); y = tea.Event.GetY(); this.Invalidate(); float x, y; PointF p; p = new PointF(x, y); foreach( PointF p in alles) met bitmap b = BitmapFactory.DecodeResource (...Icon...); Bitmap b; List alles = new List ( ) ; alles.Add(p);

(7.5) Kubus } { protected override void OnDraw(Canvas canv) { base.OnDraw(canv); public KubusView(Context c) : base(c) { } class KubusView: View public int Pos=0, Dim=2; int a = 16; float v = 255/(a-1); int d = Math.Min(Width, Height) / a; Paint verf = new Paint(); canv.DrawRect ( verf.Color = new Color( for (int y=0; y<a; y++) { } for (int x=0; x<a; x++) { v*x, v*y, Pos); d*x, d*y, d*(x+1), d*(y+1), verf); } } if (Dim==2)

Stralen class StralenApp : Activity { public override void OnCreate(Bundle b ) { base.Oncreate(b); Button knop = new Button(this); StralenView sv = new StralenView(this); knop.Click += sv.klik; LinearLayout lay SetContentView(lay); } }

Stralen StralenView(Context c) { base(c); class StralenView { } int x, y; void raakAan(obj o, TEA tea) { void klik (obj o, EA ea) { override void OnDraw (Canvas c) { } } } int n=1; } this.Touch += raakAan; this.x = tea.Event.GetX(); this.y = tea.Event.GetY(); this.Invalidate(); this.n ++; this.Invalidate(); Paint verf = new Paint(); c.DrawCircle( this.x, this.y, 40, verf ); for (int t=0; t<=this.n; t++) c.DrawLine ( this.x, this.y, this.Width * t / this.n, this.Height : View verf );

Spijkerschrift string Streepjes (int x) { } return res; for (t=0; t<x; t++) string Spijker (int x) { } return res; while (x>0) { } string res = ""; string res; res += "|"; res = ""; x = x/10; int t; x%10streepjes( ) res = + "-" + res; res = "-" + res; override void OnCreate (Bundle b) { }... TextView t = new TextView(this); t.Text = this.Spijker(456);... -||||-|||||-||||||-

Keywords nvoid nint nreturn nthis noverride nbool nnew nbase

Programma opdrachten methoden klasse variabelen en Geheugen objecten klasse zijn gegroepeerd in hebben als type veranderen bewerken

Syntax van opdrachten opdracht (), ;expressie klasse naam object expressie. methode naam =expressie;variabele property naam += returnexpressie;

opdracht for)(expropdrachtexpr ;;,, declaratie typeexprinnaamforeach()opdracht var tryblokcatch(bloknaam)type while)(expressieopdracht if)(expressieopdracht elseopdracht returnexpressie; blok

Values versus Pointers Color c; Rect r; class Rect struct Color c 0 0 R G 0 B Left Right 20 Top 40 Bottom c = new Color(255,0,0); new Rect(10,20,30,40); null r r =

Interface nIn de library nIn je eigen programma interface ISensorEventListener { } public void OnSensorChanged(SensorEvent s); class KompasView : View { } public KompasView(Context c) : base(c) { } public OnDraw(Canvas c) { } public void OnSensorChanged(SensorEvent s) { }, ISensorEventListener wat is er nodig om een ISensorEventListener te zijn? deze methode! ik beloof een ISensorEventListener te zijn en implementeer dus de methode! public void OnAccuracyChanged(SensorEvent s);

(6.3) Kompas } { protected override void OnDraw(Canvas canv) { base.OnDraw(canv); } public KompasView(Context c) : base(c) { b = BitmapFactory.DecodeResource (...UU...); } class KompasView : View public void OnSensorChanged(SensorEvent s) { } Bitmap b;float Schaal;float Hoek;, ISensorEventListener canv.DrawBitmap(b, mat, verf); Schaal = this.Width / b.Width; Matrix mat = new Matrix(); mat.PostScale(Schaal, Schaal); mat.PostRotate(- Hoek); mat.PostTranslate(Width/2, Height/2); mat.PostTranslate(-b.Width/2, -b.Height/2); Hoek = s.Values[0]; this.Invalidate( ); SensorManager sm = c. GetSystemService(...); sm.RegisterListener(this,...Orientation... ); is een geldige ISensorEventListener want zijn klasse heeft deze methode belooft methodes

{ } Color "\""+2 t=t%t; int a (Color c) return Color.Red; new Color (1,2,3) Color.Red override void() const bool b = 1==0; bool b (bool c) bool while(true); for(x=0;x++) t=0; true==false Color c; Type / Expr / Opdr / Decl / Head / X Methode T D E H X O O E OE E O T H X D T E OD H