Introduction to Java February 27, 2008 1 What is Alice? A programming environment 2 Tuesday, October 7, 2008
What is Alice? A programming language 3 What is Alice? A library of graphic objects 4 Tuesday, October 7, 2008
What is Alice? A tool that runs animations 5 What about Java? A programming environment - BlueJ 6 Tuesday, October 7, 2008
What about Java? A programming language 7 What about Java? A huge library (but less visual) 2D Graphical shapes - circles, lines, ... User interface elements - buttons, sliders, ... Networking Image manipulation... Many, many things 8 Tuesday, October 7, 2008
What about Java? A tool for running a wide range of applications 9 Objects in Alice in Java 10 Tuesday, October 7, 2008
Classes in Alice in Java 11 Methods in Alice 12 Tuesday, October 7, 2008
Methods in Java 13 Types in Alice in Java Number int double Boolean boolean Object Penguin Location Train ... 14 Tuesday, October 7, 2008
Event Handling in Alice in Java 15 Creating Objects in Alice in Java 16 Tuesday, October 7, 2008
Anatomy of a Java Class public class FallBreak extends FrameWindowController { public void onMousePress (Location point) Parameter { Instruction new Text ("Fall break is coming!", 40, 100, canvas); } Method public void onMouseRelease (Location point) { canvas.clear(); } } Class 17 Coordinate System Coordinates measure pixels, the smallest dot of color a display can make Cartesian coordinates Display coordinates 100 (0,0) 100 -100 (0,0) 100 100 -100 18 Tuesday, October 7, 2008
Methods & Constructors public class FallBreak extends FrameWindowController { Constructor call public void onMousePress (Location point) { new Text ("Fall break is coming!", 40, 100, canvas); } public void onMouseRelease (Location point) { Method call canvas.clear(); } } 19 Event Handling in Alice Need to tell Alice, which method to call when an event occurs An event can be for any mouse click or only when the mouse clicks on a specific object 20 Tuesday, October 7, 2008
Event Handling public class FallBreak extends FrameWindowController { public void onMousePress (Location point) { new Text ("Fall break is coming!", 40, 100, canvas); } public void onMouseRelease (Location point) { canvas.clear(); } } 21 Summary Many similarities in programming concepts Alice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates syntax errors, but clumsy Java programming environment - less clumsy, but requires learning syntax 22 Tuesday, October 7, 2008
Recommend
More recommend