Teaching Java using Turtles part 1

Slides:



Advertisements
Similar presentations
Introduction to Object-Oriented Programming in Alice and Java
Advertisements

Introducing Java CSC1401. Course Goals Teaching programming concepts In a “real” language.
Georgia Institute of Technology DrJava Appendix A Barb Ericson Georgia Institute of Technology May 2006.
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
Lecture 2. Review To play with Turtle, we need to download and install followings: 1.JDK 6 2.Dr. Java 3.Sample program (e.g. BookClass)
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
04-Intro-Object-Oriented-In-Java1 Barb Ericson Georgia Institute of Technology Sept 2009 Introduction to Object-Oriented Programming in Java.
Georgia Institute of Technology Introduction to Media Computation Barb Ericson Georgia Institute of Technology May 2006.
Georgia Institute of Technology Barb Ericson Georgia Institute of Technology May 2006 Teaching Java using Turtles part 1.
Methods in Java CSC1401. Overview In this session, we are going to see how to create class-level methods in Java.
CPSC1301 Computer Science 1 Overview of Dr. Java.
Georgia Institute of Technology Barb Ericson Georgia Institute of Technology May 2006 Teaching Java using Turtles part 2.
Georgia Institute of Technology Declaring Variables – Mod 4 Barb Ericson Georgia Institute of Technology August 2005.
Java Introduction part 2 CSC1401. Overview In this session, we are going to examine some of the instructions from the previous class in more detail.
Georgia Institute of Technology Declaring Variables – Mod 4 Barb Ericson Georgia Institute of Technology August 2005.
Georgia Institute of Technology Simulations Barb Ericson Jan 2005.
Georgia Institute of Technology Creating Classes part 4 Barb Ericson Georgia Institute of Technology May 2006.
Variables and Functions Alice. Naming is Important If you get a new pet one of the first things you do is name it Gives you a way to refer to the new.
Georgia Institute of Technology Creating Classes part 2 Barb Ericson Georgia Institute of Technology June 2006.
Georgia Institute of Technology Barb Ericson Georgia Institute of Technology Aug 2006 Introduction to Object-Oriented Programming in Alice and Java.
Georgia Institute of Technology More on Creating Classes part 1 Barb Ericson Georgia Institute of Technology Oct 2005.
1 Objects and Classes: creating simulations Powerpoint created by Beverly McGuire.
Georgia Institute of Technology Barb Ericson Georgia Institute of Technology Sept 2006 Introduction to Object-Oriented Programming in Alice and Java.
Georgia Institute of Technology Dr Usman Saeed Assistant Professor Faculty of Computing and Information Technology North Jeddah Branch King Abdulaziz University.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
CS1316: Representing Structure and Behavior
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Computer Programming.
Manipulating Pictures, Arrays, and Loops part 2
Manipulating Pictures, Arrays, and Loops part 2
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Classes and Objects in Java
Declaring Variables – Mod 4
Creating and Modifying Text part 2
Barb Ericson Georgia Institute of Technology Dec 2009
Introduction to Object-Oriented Programming in Alice and Java
Introduction to Object-Oriented Programming in Java
Manipulating Pictures, Arrays, and Loops part 2
Manipulating Pictures, Arrays, and Loops part 2
Introduction to Java, and DrJava part 1
Declaring Variables – Mod 4
Alice Variables Pepper.
Teaching Java using Turtles part 2
Barb Ericson Georgia Institute of Technology April 2006
Introduction to Media Computation
Teaching Java using Turtles part 3
Classes and Objects in Java
Declaring Variables – Mod 4
Barb Ericson Georgia Institute of Technology Oct 2005
Introduction to Object-Oriented Programming in Alice and Java
Workshop for Programming And Systems Management Teachers
Manipulating Pictures, Arrays, and Loops
Introduction to Java, and DrJava
Introduction to Object-Oriented Programming in Alice
CLASSES, AND OBJECTS A FIRST LOOK
Workshop for Programming And Systems Management Teachers
Overview of Java 6-Apr-19.
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
More on Creating Classes
Manipulating Pictures, Arrays, and Loops
Introduction to Java, and DrJava
Introduction to Java, and DrJava part 1
Barb Ericson Georgia Institute of Technology Oct 2005
More on Creating Classes part 3
Classes and Objects in Java
Teaching Java using Turtles
Teaching Java using Turtles part 2
The beginning of media computation Followed by a demo
Workshop for Programming And Systems Management Teachers
Presentation transcript:

Teaching Java using Turtles part 1 Georgia Institute of Technology

Georgia Institute of Technology Learning Goals To introduce computation as simulation To introduce the turtle and talk about the history of using turtles to teach programming To show how to add classes to the classpath in DrJava To create objects in Java Georgia Institute of Technology

Georgia Institute of Technology Creating a Simulation Computers let us simulate things We need to define what types of objects we will want in our simulation and what they can do Classes define the types and create objects of that type Objects act in the simulation Georgia Institute of Technology

Georgia Institute of Technology Running a Simulation How many objects does it take to get a person fed at a restaurant? Pick people to be the customer, greeter/seater, waiter, chef, and cashier and have them role play What data does each of these people need to do their job? What do they need to know how to do? What other objects do you talk about? How about simulating going to a dentist? Or to the movies? Georgia Institute of Technology

We will work with Turtle Objects We have to define what we mean by a Turtle to the computer 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 Georgia Institute of Technology

Georgia Institute of Technology Using Turtles The Turtle Class was is part of several classes created at Georgia Tech As part of a undergraduate class Add bookClasses to your classpath to use these classes This set of turtle clip art was created by Robert Savannah, an artist working for the U. S. Fish and Wildlife Service. You can find it at http://greennature.com/article1775.html. Georgia Institute of Technology

Open Preferences in DrJava Open the preferences window to add the book classes to the classpath. The classpath tells Java where to look for classes. Georgia Institute of Technology

Adding Book Classes to Classpath Add bookClasses directory Be sure to add the bookClasses directory and not bookClasses\bookClasses. Click on Add Y:\camps\Java Camp\bookClasses-2-25-09\bookClasses

Georgia Institute of Technology Creating Objects To create objects we ask the class that defines the object to create it Each object keeps a reference to the class that created it The class is like a cookie cutter It knows how much space each object needs (shape) Many objects can be created from the class World Object 1 World Object 2 World: Class Georgia Institute of Technology

Class as Object Factory A class is like a factory that creates objects of that class We ask a class to create an object by using the keyword: new ClassName We can also ask the class to initialize the object And pass data to help initialize it Georgia Institute of Technology

Creating Objects in Java In Java to create an object of a class you use new Class(value, value, …); Our Turtle objects live in a World object We must create a World object first Try typing the following in the interactions pane: new World(); Georgia Institute of Technology

Georgia Institute of Technology Creating Objects If you just do new World(); You will create a new World object and it will display But you will not have any way to refer to it again Once you close the window the object can be garbage collected The memory can be reused We need a way to refer to the new object to be able to work with it again The object is created and is in computer memory but we don’t have a way to find where it is. Georgia Institute of Technology

Georgia Institute of Technology Naming is Important If you get a new pet one of the first things you do is name it Gives you a way to refer to the new pet without saying Please take that dog we got yesterday for a walk. Please take Fifi for a walk. In programming we name things we want to refer to again Gives us a way to work with them Like the World object This is called declaring a variable Georgia Institute of Technology

Georgia Institute of Technology Summary Computers are often used for simulations Turtles have been used to teach logical thinking and geometry for decades You can add classes to the classpath in DrJava Where to look for classes that aren’t part of the Java language You can create objects of a class new Class(value1,value2) new World(); We declare variables to be able to refer to objects after they are created World earth = new World(); Turtle t1 = new Turtle(earth); Georgia Institute of Technology