Introduction to JavaFebruary 27, 2008
What is Alice?A programming environment
1
2
Tuesday, October 7, 2008
What is Alice?A programming language
What is Alice?A library of graphic objects
3
4
Tuesday, October 7, 2008
What is Alice?A tool that runs animations
What about Java?A programming environment - BlueJ
5
6
Tuesday, October 7, 2008
What about Java?A programming language
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
7
8
Tuesday, October 7, 2008
What about Java?A tool for running a wide range of applications
Objectsin Alice in Java
9
10
Tuesday, October 7, 2008
Classesin Alice in Java
Methods in Alice
11
12
Tuesday, October 7, 2008
Methods in Java
Typesin Alice in Java
Number
BooleanObject
intdoublebooleanPenguinLocationTrain...
13
14
Tuesday, October 7, 2008
Event Handlingin Alice
in Java
Creating Objectsin Alice in Java
15
16
Tuesday, October 7, 2008
Class
Method
Anatomy of a Java Class
Parameter
Instruction
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(); }}
Coordinate SystemCoordinates measure pixels, the smallest dot of color a display can make
Cartesian coordinates
(0,0) 100-100
-100
100
Display coordinates(0,0) 100
100
17
18
Tuesday, October 7, 2008
Methods & Constructors
Method call
Constructor callpublic 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(); }}
Event Handling in Alice
Need to tell Alice, which method to call when an event occursAn event can be for any mouse click or only when the mouse clicks on a specific object
19
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(); }}
SummaryMany 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
21
22
Tuesday, October 7, 2008