Getting Your Feet Green

Download Report

Transcript Getting Your Feet Green

Getting Your Feet
Green
Teaching Java in the Classroom with Greenfoot and GIMP
Introduction:

Presenter: Regan White

I am a Computer Science and Robotics teacher at
Whitesboro High School in Whitesboro, TX.

I have 20 years experience in the industry as a
programmer of business applications.

I have 9 years experience as a High School teacher.
Why?

Why teach code? The IT job market will grow 22% in the
next 6 years. *

Most of that 220,000 new jobs will be taken by people
who are not American citizens

The technology industry WILL continue to grow and it
WILL continue to accelerate it’s growth.

We need to get our kids involved so that we can get our
kids employed.
(* http://www.bls.gov/ooh/computer-and-informationtechnology/software-developers.htm 10/28/2014)
Why Java™?

Java is a very relevant choice for programming
languages in today’s world.

Java is used in every application from desktop
computers to toaster ovens and home appliances.

Java is the language of phone apps for both Android and
iPhone™.

Most importantly for young people, Java is the language
of Minecraft™. We can generate participation in coding
if we can generate interest in coding.
Why Greenfoot™?

Greenfoot teaches proper Java syntax and structures.

Greenfoot makes problem solving interesting by
presenting it as game development.

Greenfoot teaches Object Oriented Coding techniques
that are currently in use as accepted industry
standards.

Greenfoot was designed to appeal to all age groups but
young people in particular
Why Gimp™?

GIMP – The GNU Image Manipulation Program – is a fullfeatured imaged editing program that is available for
free to anyone.

In the past, GIMP suffered from a poorly designed
interface that made it difficult to use but most of those
issues have been resolved.

GIMP is very nearly as feature-rich as the full version of
Adobe Photoshop and it does NOT cost $600 per user.
Oh yeah….

…and Greenfoot is FREE!

The software may be downloaded in any quantity and
installed on any number of PCs.

Support available from http://www.greenfoot.org is
also free.

A textbook is available from Pearson – It is NOT free.
What do I need?

You need a PC and an internet connection. Currently an
edition for Android devices is under consideration but
for the immediate future the system requires Windows,
Mac, or Linux.

You need to download the software. It does not
necessarily have to be installed even. There is a version
available that will run from a flash drive.

You need to work through the lessons before you begin
teaching them. Support and help are easy to find but
you need to be familiar with the software and Java in
general.

You DON’T need to be an expert programmer!
And Now a Word from Our
Sponsor…

Not really a sponsor but I do support
http://www.code.org and the “Hour of Code” program.

We have a huge group of kids growing up today in the
Digital Age who are functionally illiterate.

We NEED coders, not just as industry programmers but
as people in other industries who can develop
applications that make their industries better.

Programming is a primary method for teaching problem
solving. More than ANYTHING we need problem solvers.

Get involved in the “Hour of Code” movement.
Let’s Get Started…

Set up process for Greenfoot…

Download zip http://www.whitesborotechnology.com/greenfoot_portable
.zip (250MB)

Extract to flash drive…

Open an explorer window to the portable you extracted to

Double-click on the Greenfoot.exe icon.

If necessary, help Greenfoot find the JDK*.

When the application opens, left click “scenario” in the
menu and then select the Wombat scenario.

When the project opens you should see a large rectangular
area with a grid in the center of the application as well as
a “tree” menu viewer on the left side of the screen.
Navigate the Interface

Greenfoot is user friendly.

The central area is the world. This is where the action
occurs.

Click the button marked “Compile” to begin.

The left side of the screen is reserved for class diagram.

Once the compile is complete, right-click the “Wombat”
class and select new Wombat(). Left click the world
and view the results.
New Wombat
Object Oriented Language
All TEKS under 130.276.c

Object: Anything. Object Oriented coding involves
creating code objects that simulate “real world” things
from blue prints called “classes”.

Class: See above. It’s a blue print used to create
objects.

Method: Code that allows objects to DO things.
Anything you can imagine, a coder can write a method
to do.

Fields: Bits of memory that describe the “state” or
condition of the object. An object can have a field
called “COLOR” that holds the color information of the
object on screen. Fields describe Objects.
Do Something!!

Once a new Wombat is added, right-click on it and
select the Move() method. The wombat reacts for one
grid square.

Continue to right-click and select Move() until the
Wombat reaches the edge of the world. What happens
on the next click?

Right-click the Act() method and see what happens.

Lets look at the code that is written for us to see
exactly what is happening.

Right-click on the Wombat again. Select “Editor” and
lets see what we have.
Code Editor
Methods Available

As we scroll through the code we see blocks of code text
organized into blocks separated by curly brackets. This is
proper java syntax for executable code.

Greenfoot does much of the heavy lifting for us. If you are
familiar with Java you should be looking for a method that
looks like this…
public static void main(String[] args)
{
//CODE GOES HERE
}

Greenfoot creates the initialization code for us in the
World and Actor classes. Students are able to focus on
creating code for the classes and methods they create.
Code Editor
Concepts We Need to Stress

As the students begin to add code we need to emphasize
the most important concepts of Java coding and Object
Oriented Programming.

Methods: Discrete blocks on executable code that
accomplish a purpose. It is considered good programming
practice to limit methods to solving one problem or
performing one action.

Parameters: Information we must pass to a method. We
place the parameters within parenthesis after the method
name.

Variables: We declare and use variables to store and
manipulate data. We must provide the data type as well as
a name. Data types can include text data (strings),
numbers (integers or floats), Boolean data (true/false), or
other types of data.
Finally Some Code…

In order to add code to a method we need to open the
editor for that class.

Right click on Wombat class in the diagram and select
“Open Editor”. This is the coding interface for the
Wombat class.

Find the method called “public void Act()”. You will
notice that methods are designated by descriptions
(declaration ), followed by open and closing curly
brackets. These mark blocks of executable code.
What can our Wombat do?

In the code editor we see two methods that we need to stress.

The first is the method with the same name as the class,
Wombat().

This method is called the constructor. It is called every time a
wombat is created. Any code we wish to run to initialize a
Wombat should be entered in this method.

We also see the Act() method. This is the main method for the
class. It is called continuously in a loop through out the life of
the object.

In our Act() method we see calls to other methods, namely
eatLeaves(), Move(), and turnLeft(). This is where the
majority of the code that controls our object will go.
Gathering Information

Click the “Reset” button and clear our world. Rightclick the Wombat class and add a new Wombat object
into our world. Right-click on a leaf and add a new leaf
into the world a few squares in front of the Wombat.

Left-click “Run” and observe what happens. We have
just called the eatLeaves(), Move() and turnLeft()
methods and eaten a leaf. Click the “Pause” button
and then right-click on our Wombat again. Click
“Inspect” from the context menu and look at the
information provided. How many leaves have been
eaten?
Lets add some variation…

Be sure you have the tutorial document open. If it is
closed then you may find it in the Greenfoot folder on
your flash drive or where ever you downloaded the
application. Go to Greenfoot and then to the Tutorial
folder and click the tutorial.html file.

Navigate to section 16 – Changing the Behavior of
an Object, in the programming section.

Copy the turnRandom method from the tutorial
file into the Wombat class using the editor.
turnRandom() method
Paste into the Wombat class

Paste or type this code into the Wombat class directly
above the last curly bracket in the editor.

Next we modify the Act() method and replace
turnLeft(); with turnRandom();

Close all editors and return to the “world” view. Click
the “Compile” button located at the bottom of the
Class diagram.

If you are not notified of an error, place a new wombat
in the world and click the run button. You have written
code to modify an object’s behavior.
Create the New Method Here
Modify the Act() method
Where to Go Next

The best way to learn to teach Java is to work through
the examples and then work through them again.

You don’t have to be a subject matter expert but you do
need to be prepared for questions. Remember
http://www.greenfoot.org and the greenroom are great
resources.