Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005.

Slides:



Advertisements
Similar presentations
IT151: Introduction to Programming
Advertisements

JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. OBJECTIVES FOR THIS UNIT Upon completion of this unit, you should be able to: Explain the Java virtual machine.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. GCOC – A.P. Computer Science A College Board Computer Science A Topics Covered Program Design - Read and understand.
Your First Java Program: HelloWorld.java
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
How to Create a Java program CS115 Fall George Koutsogiannakis.
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Hello, world! Dissect HelloWorld.java Compile it Run it.
Programming Part 1 Armond R. Smith Zhenying Wu. Overview of this Class ● Transition from FTC -> FRC ● Using Your Resources ● Java Keywords o Data Types.
Hello AP Computer Science!. What are some of the things that you have used computers for?
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
1 CSC 201: Computer Programming I B. S. Afolabi. Introduction  3 unit course  2 hours of lecture/week Thursdays 4.00pm – 6.00pm Mondays 4.00pm – 6.00pm.
INTRODUCTION TO JAVA CHAPTER 1 1. WHAT IS JAVA ? Java is a programming language and computing platform first released by Sun Microsystems in The.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
CSC204 – Programming I Lecture 4 August 28, 2002.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
JAVA BASICS: Variables and References SYNTAX, ERRORS, AND DEBUGGING.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
Introduction to programming in the Java programming language.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
8/31: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Java.
Anatomy of a Java Program. AnotherQuote.java 1 /** A basic java program 2 * 3 Nancy Harris, James Madison University 4 V1 6/2010.
Hello Computer Science!. Below is an example of a Hello World program in JAVA. While it is only three lines of code, there are many things that are happening.
CS 106 Introduction to Computer Science I 01 / 22 / 2007 Instructor: Michael Eckmann.
Java FilesOops - Mistake Java lingoSyntax
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
CS 106 Introduction to Computer Science I 01 / 22 / 2008 Instructor: Michael Eckmann.
CS 177 Recitation Week 1 – Intro to Java. Questions?
ITP 109 Week 2 Trina Gregory Introduction to Java.
1/16: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.
CS 106 Introduction to Computer Science I 01 / 24 / 2007 Instructor: Michael Eckmann.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
Terms: Software  Set of instructions  aka programs  Operating System:  Special software whose job it is to translateinstructions into hardware instructions.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Eastside Robotics Alliance / Newport Robotics Group 1 T/Th, 6:30 – 8:30 PM Big Picture School Day 3 · 10/9/2014.
Computer Programming Your First Java Program: HelloWorld.java.
Dept of Computer Science University of Maryland College Park
Building Java Programs
Introduction to.
Computer Programming Methodology Introduction to Java
CompSci 230 Software Construction
Tonga Institute of Higher Education
Building Java Programs
Java Intro.
Building Java Programs Chapter 2
COM-152: Computer Programming Types, Variables, Operators Part 1 of 2
Anatomy of a Java Program
Chapter 2 Programming Basics.
Building Java Programs
Building Java Programs
Building Java Programs Chapter 2
Building Java Programs
Presentation transcript:

Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005

Computer Program A way to get a computer to do something

Programming Language A way of writing computer programs that is (potentially) comprehensible by people.

Interpreted vs. Compiled Interpreted – one line at a time. Compiled: Person-> Source Code -> Machine Code -> Computer

Source code Human-readable text that can be used to make a computer operate in a certain way.

Commenting A way to get the computer to ignore certain parts of a computer program. Useful for: –Identifying the function of certain lines of code –Temporarily removing parts of programs –Leaving notes for yourself and others

Object Oriented Programming Wikipedia – “the idea that a computer program is composed of a collection of individual units, or objects, as opposed to a traditional view in which a program is a list of instructions to the computer.”

Java A compiled language An object oriented language Derived largely from C/C++

Java Source Code /** * Written on Sep 26, 2005 by Bill Tomlinson */ public class MinimalPrintOutProgram { public static void main(String[] args) { //Note: this program is often called "Hello World." System.out.println("Hello there."); }

Curly Braces Demarcate different sections of code. Nested braces { Section 1 { Section 1a } { Section 1b }

Parentheses Different from curly braces Enclose arguments (we’ll get to arguments in a moment)

Semicolons There’s one at the end of every statement.

Line Spacing Irrelevant to the computer. Useful for keeping track of what is going on in complex code.

Classes These are the objects in “Object oriented programming”.

Fields Similar to nouns in the English language. They store data. Some important data types: –int – a number with no decimal places –float – a number with some decimal places –double – a number with lots of decimal places –String – a group of letters (and numbers) Give examples

Methods Like verbs in English Methods are actions that objects can perform They manipulate fields and interact with other objects.

Arguments Methods sometimes include arguments, that is, fields which are “passed in” to the method to allow it to act on them.

Types and Names Creates a reference to a chunk of memory of a certain type. May or may not put information into that memory space. int age; String name = “Bill”;

Arrays A way of grouping things String [] names = new String[3]; names[0] = “bill”;

Booleans true or false boolean myNameIsBill = true;

Loops Lets the program do something over and over again (which computers are very good at). for (int i = 0; i < 5; i ++) { System.out.println(“Round number “ + i); }

Conditionals if (age>18 && liveInUS) { vote(); }

System.out.println(); A way to print something out. Useful for debugging.

Three Kinds of Commenting // /* */ /** * */

// //This line is now commented out // I can also leave myself notes like this.

/* */ /* This kind of comment is useful for commenting out long blocks of code. */

/** * *This is yet a third kind of comment. *It is used to describe the content that *is coming next. * */

Capitalization By convention: ClassesAreCapitalizedLikeThis methodsAreCapitalizedLikeThis someFieldsAreCapitalizedLikeThis OTHER_FIELDS_LIKE_THIS (We’ll get to that distinction later.)

Field and Method Names Should be descriptive Long is okay. There are tools in Eclipse that make it easier. For now, even with notepad and javac, make sure to use descriptive names.

Questions about any of the letters? /** * Written on Sep 26, 2005 by Bill Tomlinson */ public class MinimalPrintOutProgram { public static void main(String[] args) { //Note: this program is often called "Hello World." System.out.println("Hello there."); }

A Longer Example (From your first assignment.)

Writing Code You may not (and probably won’t) understand everything about the code you’re working with.

Notepad, Javac and Java Walk through it together.

Applets Web based applications. Require one or more java class files and an html file.

Debugging Coding is an iterative process. Debugging is the bulk of the work, especially at first. Three Kinds of Bugs –Compile time –Run time –Misbehavior

Compile-Time Bugs Javac will not convert the.java files into.class files. Need to fix the code before you can even run it.

Run-Time Bugs Javac will converty the.java files into class files, but the code crashes somewhere. May crash before the code “works” at all, or it may crash after running for a while.

Misbehavior Code compiles and runs but… It doesn’t do what you want. Part of the challenge is often figuring out why it’s doing what it’s doing.

Assignment 1 Make a graphical computer program. You may use BasicGraphicsSystem.java, which I have provided, or you may use this as an opportunity to go learn JOGL or some other graphics system.

If There Is Time Left Start working on Assignment 1, and I will help out as needed.