+ All Categories
Home > Documents > Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating...

Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating...

Date post: 11-Jul-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
11
Introduction to Java February 27, 2008 What is Alice? A programming environment 1 2 Tuesday, October 7, 2008
Transcript
Page 1: Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates

Introduction to JavaFebruary 27, 2008

What is Alice?A programming environment

1

2

Tuesday, October 7, 2008

Page 2: Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates

What is Alice?A programming language

What is Alice?A library of graphic objects

3

4

Tuesday, October 7, 2008

Page 3: Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates

What is Alice?A tool that runs animations

What about Java?A programming environment - BlueJ

5

6

Tuesday, October 7, 2008

Page 4: Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates

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

Page 5: Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates

What about Java?A tool for running a wide range of applications

Objectsin Alice in Java

9

10

Tuesday, October 7, 2008

Page 6: Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates

Classesin Alice in Java

Methods in Alice

11

12

Tuesday, October 7, 2008

Page 7: Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates

Methods in Java

Typesin Alice in Java

Number

BooleanObject

intdoublebooleanPenguinLocationTrain...

13

14

Tuesday, October 7, 2008

Page 8: Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates

Event Handlingin Alice

in Java

Creating Objectsin Alice in Java

15

16

Tuesday, October 7, 2008

Page 9: Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates

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

Page 10: Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates

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

Page 11: Introduction to Javablerner/cs101/Slides/Lecture09JavaIntro.pdfAlice - limited to creating animations Java - wide applicability Alice programming environment - menu, drag&drop eliminates

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


Recommended