programming
play

Programming What is a program? A set of instructions Understood by - PowerPoint PPT Presentation

Programming What is a program? A set of instructions Understood by a computer What does a program look like? An algorithm is a set of instructions designed to accomplish a specific goal For a temperature f in Fahrenheit


  1. Programming  What is a program?  A set of instructions  Understood by a computer

  2. What does a program look like?  An algorithm is a set of instructions designed to accomplish a specific goal  For a temperature f in Fahrenheit  Subtract 32 from f.  Divide f by 1.8.  Display the value of f.  [Converts to Celsius]  Don’t need to understand the goal to follow instructions

  3. Programming Languages  A language is a tool with which we tell a computer an algorithm  Compilers translate from one computer language to another  Each language has own advantages and disadvantages

  4. What is Alice?  A programming environment.

  5. What is Alice?  A programming language.  A library of graphic objects

  6. What is Alice? A tool for running animations

  7. What about JAVA?  BlueJ - a programming environment designed to teach programming

  8. The Java Language  A programming language (Widely Used) public class TouchyWindow extends WindowController { public void onMousePress ( Location point ) { new Text("I’m touched", 40, 50, canvas ); } public void onMouseRelease( Location point ) { canvas.clear(); } }  Can be compiled on many computer systems

  9. 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  A tool for running a wide range of applications

  10. Methods in Java public class TouchyWindow extends WindowController { public void onMousePress ( Location point ) { new Text("I’m touched", 40, 50, canvas ); } public void onMouseRelease( Location point ) { canvas.clear(); } }

  11. Types  Number  int  double  Boolean  boolean  Object  Penguin  Location  Train  …

  12. Event Handling In Alice: In Java: public class TouchyWindow extends WindowController { public void onMousePress ( Location point ) { new Text("I’m touched", 40, 50, canvas ); } public void onMouseRelease( Location point ) { canvas.clear(); } }

  13. Creating Objects  In Java:  In Alice: In Java: public class TouchyWindow extends WindowController { public void onMousePress ( Location point ) { new Text("I’m touched", 40, 50, canvas ); } public void onMouseRelease( Location point ) { canvas.clear(); } }

  14. Anatomy of a Java Class: set, collection group, or configuration containing members regarded as having certain attributes or traits in common import objectdraw.*; import java.awt.*; public class TouchyWindow extends WindowController { parameter public void onMousePress ( Location point ) { new Text("I’m touched", 40, 50, canvas ); Instruction } Method public void onMouseRelease( Location point ) { canvas.clear(); } class }

  15. Coordinate system  Coordinates measure pixels, the smallest dot of color a display can make

  16. Methods and Constructors public class TouchyWindow extends WindowController { public void onMousePress ( Location point ) { Constructor call new Text("I’m touched", 40, 50, canvas ); } public void onMouseRelease( Location point ) { canvas.clear(); Method call } }

  17. Graphical Objects new Text ( "I’m Touched", 40, 50, canvas );  new an instruction that tells we want to construct a new object  Text the object we want to construct  (…) comma delineated “parameters” that tell how to construct the object  ; semicolons are important too!  every command semicolon terminated

  18. Graphical Objects new Text ( "I’m Touched", 40, 50, canvas );

  19. Events In Alice, need to specify which method to call when an event occurs Java: public void onMousePress( Location point )  Will run the code when mouse button is pressed  onMouseRelease:  Runs code when the buttons released  Many more mouse event handling methods

  20. Summary  Many 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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend