1 / 20

415.111 SC Introduction to Programming Lecture 1: 5 th May 2003

415.111 SC Introduction to Programming Lecture 1: 5 th May 2003. Course Information. Lecturer: Dr Jennifer Lennon Room 565 email: jennifer@cs.auckland.ac.nz Office hours: Mon (2-3), Wed (2-3),. Course composition. Labs 15% Test 20% Final Exam 65% Lectures Final exam

Download Presentation

415.111 SC Introduction to Programming Lecture 1: 5 th May 2003

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 415.111 SC Introduction to Programming Lecture 1: 5th May 2003

  2. Course Information • Lecturer: • Dr Jennifer Lennon • Room 565 • email: jennifer@cs.auckland.ac.nz • Office hours: Mon (2-3), Wed (2-3),

  3. Course composition • Labs 15% • Test 20% • Final Exam 65% • Lectures Final exam • Homework Final exam • Labwork Final exam

  4. . Course Information contd • Text • The Explorer’s Guide to Programming (to be collected (FREE OF CHARGE) from the Resource Centre) • Lecture notes (for revision) • Labs – as usual

  5. This lecture: Outline • What is programming? • What is Java? • How do we run a Java program? • What is a program? • Introduction to Applets: • The coordinate system • Drawing text in the Applet window

  6. What is programming? • Getting the computer to follow our instructions • E.g. Alice as well as all the Microsoft Office applications are programs

  7. Why Learn programming? • To better understand how computers work • To make more intelligent guesses when they don’t work • In industry: • 80% work can be done by applications • 20% must be done by programmers

  8. What language will we use? • Java • Why??? • It is a good teaching language • This is the Computer Science dept. • Follows through to COMPSCI.101 • It is a language for professionals • Is programming an art or a science? • Both

  9. For Success in Learning Java • Attend all lectures • Read every word of the Explorer’s Guide • Do every exercise in the Explorer’s Guide • Attend all tutorials • Complete every assignment • You only learn by writing programs yourself

  10. What is a program? • It is a series of statements. • For example the statement: • g.drawString("Hello Computer", 50, 100); • Displays Hello Computer on the computer screen. • What happens if we make a mistake? • The computer displays an error message, or • it does something unexpected.

  11. Running a program  Open the 111 Course folder  Open the Explorer’s Guide folder  Open the Sample programs folder • Copy the Chapter 1-progs to your G:drive. • Open the program of you want to run

  12. Running a program continued: Double click on the FirstHello.java file

  13. Running a program contd  Now choose Run Java Applet from the Tools menu After a short wait the following window appears:

  14. The Program p9

  15. Painting in the Applet Window • The following line tells the Java system that we are going to draw in the Applet window: • public void paint( Graphics g ) • In Java terminology we say that we are going to "paint" in the window.

  16. The Applet Window: a grid Pixels:

  17. The g.drawString() Statement • g.drawString( "Hello World!", 30, 30 ); • This tells the system that we are going to draw the string "Hello World!" at position (30, 30) in the Applet window.

  18. Co-ordinates p10

  19. Positioning the text p12 (30,30) g.drawString("Zing!", 30, 30 );

  20. Changing the font and font size p12 • g.setFont() • // * * * * * * * * * * * * * * * * * * * * * * * • // Hello Computer program revisited • g.setFont( new Font ( "TimesRoman", Font.BOLD, 18 )); • g.drawString( "Hello Computer!", 30, 30 ); • // * * * * * * * * * * * * * * * * * * * * * * *

More Related