programming language features syntax semantics. syntax diagram

Post on 17-Dec-2015

315 Views

Category:

Documents

9 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Programming Language Features

• Syntax• Semantics

Syntax Diagram

Syntax Diagram

Syntax Diagram

Syntax Diagram

Syntax Diagram

Syntax Diagram

Syntax Diagram

Syntax Diagram

Syntax Diagram

Drawing Gizmo Example// Example program with parameters that displays a T// The T is drawn by the method drawT

public class Driver { private DrawingGizmo pencil; public void drawT() { //Draws a letter T //PRE: Assumes the current position of the pen is the // leftmost postion of the top of the T and the direction // of the pen is 0 degrees //POST: The method leaves the pen at the rightmost // position of the top of the T and the direction of the // pen is 0 degrees pencil.draw(); pencil.turnBy(90); pencil.moveBy(80);

Drawing Gizmo Example //Move the pen to the middle of the top of the T pencil.dontDraw(); pencil.turnBy(-180); pencil.moveBy(40); //Draw the vertical part of the T pencil.draw(); pencil.turnBy(-90); pencil.moveBy(120); //Move pen to the rightmost position of the top of the T //leave the direction of the pen at 0 degrees pencil.dontDraw(); pencil.turnBy(180); pencil.moveBy(120); pencil.turnBy(90); pencil.moveBy(40); pencil.turnBy(-90); }

Drawing Gizmo Example

public Driver() { pencil = new DrawingGizmo(); //Move the pen to the left pencil.dontDraw(); pencil.turnBy(-90); pencil.moveBy(80); pencil.turnBy(90); drawT();

}}

top related