Espresso! A small cup of JavaEspresso! is:Key FeaturesSlide 4Slide 5Slide 6Slide 7Slide 8A Taste of Espresso! Hello, World!Slide 10A Taste of Espresso! Data Types and ObjectsA Taste of Espresso! Program StructureA Taste of Espresso! Type DeclarationsA Taste of Espresso! Array DeclarationsA Taste of Espresso! AssignmentsA Taste of Espresso! Sample ProgramSlide 17A Taste of Espresso! DevelopmentSlide 19A Taste of Espresso! StateSlide 21A Taste of Espresso! ScopeA Taste of Espresso! Runtime LibraryA Taste of Espresso! Runtime Library DefinitionA Taste of Espresso! TestingLessons LearnedFuture DevelopmentsEspresso!Espresso!A small cup of JavaA small cup of Java•Erin Adelman - [email protected]•Aaron Bauman - [email protected]•Philip Coakley - [email protected]•Joya Zuber - [email protected] Programming Languages and TranslatorsProfessor Stephen Edwards, December 200301/14/19 Espresso! Programming Language 2Espresso! Espresso! is:is: A simple and efficient way for programmers of all levels to create java applets.An educational language to familiarize novice programmers with java syntax.Similar to Tcl and Java in syntax and semantics01/14/19 Espresso! Programming Language 3Key FeaturesKey FeaturesSimple01/14/19 Espresso! Programming Language 4Key FeaturesKey FeaturesSimpleEducational01/14/19 Espresso! Programming Language 5Key FeaturesKey FeaturesSimpleEducationalObject-Oriented01/14/19 Espresso! Programming Language 6Key FeaturesKey FeaturesSimpleEducationalObject-OrientedPortable01/14/19 Espresso! Programming Language 7Key FeaturesKey FeaturesSimpleEducationalObject-OrientedPortableEfficient01/14/19 Espresso! Programming Language 8Key FeaturesKey FeaturesSimpleEducationalObject-OrientedPortableEfficientScalable01/14/19 Espresso! Programming Language 9A Taste of A Taste of Espresso!Espresso!Hello, World!Hello, World!card HelloWorld {print(“Hello World!”);}01/14/19 Espresso! Programming Language 10A Taste of A Taste of Espresso!Espresso!Hello, World!Hello, World!01/14/19 Espresso! Programming Language 11A Taste of A Taste of Espresso!Espresso!Data Types and ObjectsData Types and Objectsnumber–Java doublestring–Java Stringnumber array–Java double[]string array–Java String[]object arrayobject–TextBox–Button–CheckBox–List–Image–Oval–Rectangle01/14/19 Espresso! Programming Language 12A Taste of A Taste of Espresso!Espresso!Program StructureProgram Structurecard card_name {statement;statement;…statement;}01/14/19 Espresso! Programming Language 13A Taste of A Taste of Espresso!Espresso!Type DeclarationsType Declarationsnumber phil = 5;: double phil = 5; string joya = “Joya”;: String joya = “Joya”;TextBox myTextBox;: EspressoTextBoxRT myTextBox = new EspressoTextBoxRT();01/14/19 Espresso! Programming Language 14A Taste of A Taste of Espresso!Espresso!Array DeclarationsArray Declarationsnumber[3] aaron = 5.4;: double[] aaron = new double[3];for( int i=0; i<3; i++ ) aaron[i] = 5.4;01/14/19 Espresso! Programming Language 15A Taste of A Taste of Espresso!Espresso!AssignmentsAssignmentsphil = phil + 5;joya = joya + “ is cool”;aaron[2] = 5;erin[0] = “Sneak”;myButton.setWidth(phil);01/14/19 Espresso! Programming Language 16A Taste of A Taste of Espresso!Espresso!Sample ProgramSample ProgramEspresso! program (21 lines)card HelloWorld { Image baby; baby.setSource("http://www.columbia.edu/~adb54/baby.jpg"); Oval myOval; number cx = 150; number cy = 90; number cwidth = 100; number cheight = 50; myOval.setX(cx); myOval.setY(cy); myOval.setWidth(cwidth); myOval.setHeight(cheight); myOval.setColor(red); Rectangle myRectangle; myRectangle.setX(cx + 7); myRectangle.setY(cy + 30); myRectangle.setWidth(20); myRectangle.setHeight(20); print("Hello, World!", cx+10, cy+25);}Java program (106 lines)import java.awt.*;import java.awt.event.*;import java.applet.*;import java.net.*;import java.util.*;public class HelloWorld extends Applet implements Runnable{ Image img; Graphics g2 = null; Image I2; int sx; int sy;…… public synchronized void paint(Graphics g) {g = getGraphics();I2 = createImage(getWidth(), getHeight());Graphics temp = I2.getGraphics();temp.setColor(getBackground());temp.fillRect(0, 0, getWidth(), getHeight());temp.drawImage(img, 0, 0, this);temp.setColor(Color.white);… …01/14/19 Espresso! Programming Language 17A Taste of A Taste of Espresso!Espresso!Sample ProgramSample Program01/14/19 Espresso! Programming Language 18A Taste of A Taste of Espresso!Espresso!DevelopmentDevelopmentCreate and analyze sample applets with desired Espresso! functionality. Java applet control flow and event handling are confusing.How can we abstract this applet architecture from the user?A robust back end!01/14/19 Espresso! Programming Language 1901/14/19 Espresso! Programming Language 20A Taste of A Taste of Espresso!Espresso!State State The walker and Code Generation class work together to maintain 5 states:–Declaring–Initializing–Executing–Drawing–Action ListeningEach state represents a section in the generated applet file.DeclarationsInitializationsActionsDrawExecutepublic class myApplet extends applet {}01/14/19 Espresso! Programming Language 21A Taste of A Taste of Espresso!Espresso!State State card HelloWorld { Image baby; baby.setSource("http://www.columbia.edu/~adb54/baby.jpg"); Oval myOval; number cx = 150; number cy = 90; number cwidth = 100; number cheight = 50; myOval.setX(cx); myOval.setY(cy); myOval.setWidth(cwidth); myOval.setHeight(cheight); myOval.setColor(red); Rectangle myRectangle; myRectangle.setX(cx + 7); myRectangle.setY(cy + 30); myRectangle.setWidth(20); myRectangle.setHeight(20); print("Hello, World!", cx+10, cy+25);}DeclarationsInitializationsActionsDrawExecutepublic class myApplet extends applet {}01/14/19 Espresso! Programming Language 22A Taste of A Taste of Espresso!Espresso!ScopeScopeThink GloballyEspresso! has a single scopeVariables can be declared at any time in Espresso!, but will all be initialized globally in the generated Java file.01/14/19 Espresso! Programming Language 23A Taste of A Taste of Espresso!Espresso!Runtime Library Runtime Library The Runtime Library includes a suite of wrapper classes that build AWT
View Full Document