Concepts From Alice Switching to Java Copyright © 2006-2017 Curt Hill
Concepts We Have Seen Concepts Objects Looping statements Blocks Concurrency Variables Bugs We should have seen the equivalent Java code for Alice statements Copyright © 2006-2017 Curt Hill
The Process Programming is bossing the machine around Making it do what you want When it does not do what you intended it is a bug A program is a sequence of statements that accomplish this There are many little details that must be right for good results Copyright © 2006-2017 Curt Hill
Objects A self contained piece of code Methods, properties, events An object may be composed of smaller objects We may do things to the larger object We may also do things to the contained objects Copyright © 2006-2017 Curt Hill
More on Objects Alice objects are obtained from gallery We may drag in an object more than once In Java we have classes and objects An object being an instance of a class The Java library is much larger than the Alice gallery Often we specify the portion of the library that contains the class we need Copyright © 2006-2017 Curt Hill
Variables An item that may contain a value Two kinds in Java Primitive types contain simple things like an integer or character Similar to Alice parameter values Objects Contains values and methods Values may be primitive or other objects Copyright © 2006-2017 Curt Hill
Decision statements Java decision statements are actually easier to create than those of Alice Type rather than drag and drop Two types of decision If Similar to Alice Based on boolean Switch case Multi-way decision Copyright © 2006-2017 Curt Hill
Looping statements There are three loops in Java compared to two in Alice The for is the counting loop Most similar to the Loop of Alice The while of Java is similar to the Alice while The do of Java is a trailing decision loop There are no trailing decision loops in Alice Copyright © 2006-2017 Curt Hill
Blocks The statements of a Do Together, Do In Order, If, Loop etc. form a block A block is a container that holds one or more statements Bundles these together as one The Java block is just a pair of braces { } It is stronger than that of Alice Copyright © 2006-2017 Curt Hill
Concurrency Java handles concurrency very well for a language It is not nearly as easy to use as in Alice It is unlikely that we will cover in this class The important terms in Java are: thread runnable interface Copyright © 2006-2017 Curt Hill
Event Handling An event is some action that occurs at an unpredictable time A user types a key Event handling is the action that a program does in response to the event We will likely see event handling in regards to a user clicking a button in Java Copyright © 2006-2017 Curt Hill
Environment In early programming languages the entire program was typed Today we usually use a combination Drag and drop Used to design the window Initialize event handling Typing Enter the central logic of the program Copyright © 2006-2017 Curt Hill
Java Environment There are many, some are even free We will use Eclipse Java SE You should download this soon Even as you are still working on the Alice program Copyright © 2006-2017 Curt Hill
Finally This concludes our short detour through Alice Alice shows all the features of a general purpose language Since you are able to create Alice programs you are also able to create Java programs Even if it is not quite as fun or easy Copyright © 2006-2017 Curt Hill