Introducing Java CSC 1401 Course Goals Teaching programming

  • Slides: 23
Download presentation
Introducing Java CSC 1401

Introducing Java CSC 1401

Course Goals Teaching programming concepts In a “real” language

Course Goals Teaching programming concepts In a “real” language

Course Approach Alternate between Alice and Java as we learn programming concepts Some concepts

Course Approach Alternate between Alice and Java as we learn programming concepts Some concepts we’ll explore first in Alice Others we’ll explore first in Java The problem of Java It’s hard We’ll use specially created graphics libraries to help us

Java libraries What is a Java library? It’s just a class or several classes

Java libraries What is a Java library? It’s just a class or several classes In Alice, classes were located Local Gallery CD Gallery Web Gallery In Java, we’ll need to tell the computer where to find the classes Setting the classpath (this is the directory where the classes will be located) Or, using an import statement in our Java program We’ll see how to do this in lab on Friday

Important object-oriented concepts Class Object Method Parameter Sequencing (Do in order vs. Do together)

Important object-oriented concepts Class Object Method Parameter Sequencing (Do in order vs. Do together) Design

Alice Java similarities We are going to find that Alice and Java are quite

Alice Java similarities We are going to find that Alice and Java are quite similar, and that concepts learned in one language immediately apply to the other There are some differences, mostly mechanical, between the 2 languages

Some differences between Java and Alice uses a drag and drop editor Java has

Some differences between Java and Alice uses a drag and drop editor Java has Integrated Development Environments (IDEs) that generally require typing code. We’ll be using one called JGrasp

Alice-Java Differences Classes are found in the local gallery, the CD gallery, or the

Alice-Java Differences Classes are found in the local gallery, the CD gallery, or the web gallery Classes can be located anywhere, but you need to tell the computer where they are

Alice-Java Differences The main program is generally world. my first method The main program

Alice-Java Differences The main program is generally world. my first method The main program is generally public static void main (String [] args)

Alice-Java Differences In Alice, objects are added to a world by dragging them and

Alice-Java Differences In Alice, objects are added to a world by dragging them and dropping them into position In Java, we use the new keyword. We also use the constructor to specify such things as where to place them.

Alice-Java Differences In Alice each method is located on a separate window – but

Alice-Java Differences In Alice each method is located on a separate window – but you can export all of the dragon’s methods into a single html file In Java, all of the methods for a single class are in one window

Alice – Java Differences File names always end in. a 2 w (and sometimes.

Alice – Java Differences File names always end in. a 2 w (and sometimes. a 2 c) File names always end in. java

Alice-Java Differences To run an Alice program, just click on the play button Running

Alice-Java Differences To run an Alice program, just click on the play button Running a Java program is a 2 -step process: 1) Click on compile. This will make sure you don’t have any typos and generates a. class file 2) Click on Run

Alice-Java differences In Alice, an object’s methods are located in the object pane at

Alice-Java differences In Alice, an object’s methods are located in the object pane at the lower left of the screen In Java, we need to look at an html file (called Javadoc- short for Java documentation) to see an object’s methods

Alice – Java differences In Alice most objects (except for billboards) are 3 D

Alice – Java differences In Alice most objects (except for billboards) are 3 D In Java, most of our objects will be 2 D. Java supports 3 D, but it’s much harder to program.

Java Example: Turtles We will work with Turtles in a World in Java We

Java Example: Turtles We will work with Turtles in a World in Java We do this by writing a Turtle class definition Turtle. java We compile it to convert it into something the computer can understand Bytes codes for a virtual machine Turtle. class

History of Turtles Seymour Papert at MIT in the 60 s By teaching the

History of Turtles Seymour Papert at MIT in the 60 s By teaching the computer to do something the kids are thinking about thinking Develop problem solving skills Learn by constructing and debugging something Learn by making mistakes and fixing them

JGrasp Demo Opening a new Java file

JGrasp Demo Opening a new Java file

Using Turtles Add book. Classes to your classpath to use these classes

Using Turtles Add book. Classes to your classpath to use these classes

Telling JGrasp where to find the Turtle class

Telling JGrasp where to find the Turtle class

Classpath part 2 → Then click on OK Then click on Apply Then click

Classpath part 2 → Then click on OK Then click on Apply Then click OK

Turtle Demo Writing a Turtle program class public static void main(String [] args) {}

Turtle Demo Writing a Turtle program class public static void main(String [] args) {} versus ; // and /* new Compiling and running and stopping Looking at the Javadoc

Assignment Read Media Computation Chapter 3, Sections 1 through 5 Classes Objects Methods

Assignment Read Media Computation Chapter 3, Sections 1 through 5 Classes Objects Methods