Chapter 1 - Getting to know Greenfoot Acknowledgement: Michael Kolling & Bruce Chittenden.

Slides:



Advertisements
Similar presentations
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Advertisements

Problem Solving with Data Structures using Java: A Multimedia Approach Chapter 14: Using an Existing Simulation Package Download greenfoot and install.
Getting to know Greenfoot
Games and Simulations O-O Programming in Java The Walker School
of Kent A practical introduction to Greenfoot David Barnes Lecturer in Computer Science University of.
Chapter 2 - The First Program: Little Crab
Program: Little Crab Mr Gano.
Asteroids Games and Simulations O-O Programming in Java The Walker School The Walker School – Games and Simulations
Greenfoot Asteroids Mrs. C. Furman August 16, 2010.
Wombats Creating Games with Greenfoot The Walker School – Games and Simulations
Chapter 1 - Getting to know Greenfoot Bruce Chittenden.
Object-Oriented Analysis and Design
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Objects First with Java A Practical Introduction using BlueJ
Exploring Office Grauer and Barber 1 Creating More Powerful Applications: Introduction to VBA(Wk9)
Copyright by Scott GrissomCh 1 Objects and Classes Slide 1 Classes and Objects A Class refers to something in general describes a category of items a cookie.
CO320 Introduction to Object- Oriented Programming Michael Kölling 3.0.
Vocabulary Key Terms polymorphism - Selecting a method among many methods that have the same name. subclass - A class that inherits variables and methods.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Chapter 5 - Making Music: An On-Screen Piano
Chapter 2 (Horstmann’s Book) – Part 2 The Object-Oriented Design Process Hwajung Lee.
1 Programming James King 12 August Aims Give overview of concepts addressed in Web based programming module Teach you enough Java to write simple.
Created by NW 2012 – please note all copyright on images used is property of copyright holder. Note: some of the more complicated descriptions are taken.
Problem Solving with Data Structures using Java: A Multimedia Approach Chapter 14: Using an Existing Simulation Package.
5.0 Objects First with Java A Practical Introduction using BlueJ Introduction to Computer Science I Instructor: Allyson Anderson.
Greenfoot. Getting Started Open the Greenfoot download site: Select Greenfoot
CSE 113 Introduction to Computer Programming Lecture slides for Week 2 Wednesday, September 7 th, 2011 Instructor: Scott Settembre.
Object Oriented Programming April 13, Problem Description “ …Wombats are allowed to have different directions and number of eaten leaves, move,
CSE 501N Fall ‘09 14: Inheritance 20 October 2009 Nick Leidenfrost.
Chapter 1 - Getting to know Greenfoot
Systems Analysis & Design 7 th Edition Chapter 5.
Lecture 4. Greenfoot 1 Pablo Romero, Department of Informatics Greenfoot Programming simulations and games in Java.
Microsoft Office XP Illustrated Introductory, Enhanced Started with Windows 2000 Getting.
Greenfoot Game Programming Club.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
Lesson 1: Writing a program. Java Java is a programming language Computer cannot understand it, though it can be translated ( compiled ) so a computer.
Kakihijau.googlepages.com Introduction To Greenfoot Part-1.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
Kakihijau.googlepages.com Introduction To Greenfoot Part-2.
INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify.
Introduction To Greenfoot
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Polymorphism. Superclass and Subclass Inheritance defines a relationship between objects that share characteristics. It is a mechanism.
Georgia Institute of Technology More on Creating Classes part 3 Barb Ericson Georgia Institute of Technology Nov 2005.
Chapter 2 – The Little Crab Program:. Little Crab Scenario Inheritance: The Arrows Denote Hierarchy Crab is an Animal Animal is an Actor Therefore, It.
Adding and Eating Worms Mrs. C. Furman August 23, 2010.
Kakihijau.googlepages.com Introduction To Greenfoot Part-3.
Chapter 4 - Finishing the Crab Game
Chapter 4 - Finishing the Crab Game
Objects and Classes CITS1001 week 1.
Objects First with Java A Practical Introduction using BlueJ
Introduction To Greenfoot
Introduction to Object-oriented Program Design
Creating Games with Greenfoot
Version 2.
The Little Crab Scenario
COS 260 DAY 2 Tony Gauvin.
Problem Solving with Data Structures using Java: A Multimedia Approach
Games and Simulations O-O Programming in Java The Walker School
Classes and Objects Still Chapter 1.
Objects First with Java A Practical Introduction using BlueJ
Introduction to Object-Oriented Programming in Alice
Interlude 1 - Sharing Your Scenarios
Methods, Data and Data Types
Greenfoot November 8, 2009.
Objects First with Java A Practical Introduction using BlueJ
Chapter 5.
1.7 A Second Example.
Presentation transcript:

Chapter 1 - Getting to know Greenfoot Acknowledgement: Michael Kolling & Bruce Chittenden

Greenfoot Resources Web site – Scenarios – /index.html /index.html Tutorial – al.html al.html Book: Introduction to Programming with Greenfoot by Michael Kölling

Desktop Icon

1.1 Getting Started World Class Diagram Execution Controls

World A Finite space where our program runs. Space where we can introduce some actors Allow actors to Interact

Class Diagram Shows Classes involved in the scenario Classes define general characteristics or behavior of a group Characteristics that are easily differentiable Is-A- Relationship Subclass relationship Diagram contains Boxes called Class boxes WombatWorld is a subclass of World Wombat is a subclass for Actor Leaf is a subclass of Actor Leaf is not a subclass of Wombat Actor is the super class of Leaf and Wombat

Class Hierarchy TeacherStudent Humans Mammals food() drink() think() react() enroll () study() submit_Assignments() teach () evaluate() prepare_Assignments()

1.2 Objects and Classes Right Click on Wombat Click New Wombat() Drag to World

Multiple Objects We can create multiple instances of same class

Exercise 1.1

1.3 Interacting with Objects Wombat has certain function of its own And Certain function inherited from Actor class

Interacting with Objects Invoke the Move method Right Click on the Wombat

1.4 Return Types

Exercise 1.3

Exercise 1.4

1.5 Parameters

Exercise 1.5

Parameter > 3 Does Nothing

Exercise 1.5 Non-Integer Returns Error

1.6 Greenfoot Execution

Exercise 1.6

Wombat Moves toward the Leaves

Exercise 1.6 Wombat Moves to Leaves

Example 1.7 Wombat Eats Leaf

Exercise 1.8

The >Act Execution Control Affects All the Wombats

Exercise 1.9 Wombat Runs Around the Edge of the World

Exercise 1.9 Act Method – If we’re sitting on a leaf, eat the leaf – Otherwise, if we can move forward, move forward – Otherwise, turn left

1.7 A Second Example

1.8 Understanding the Class Diagram World Class is always there in Greenfoot scenarios, it is built-in. Space represents a specific world for this scenario Arrows show relationships Explosion and Mover are subclasses of Actor Bullet, Rocket, and Asteroid are subclasses of Mover. Vector is a helper class

1.9 Playing with Asteroids Start Playing by Creating Some Actor Objects (Objects of the Subclass of Actor). Create Objects for Rocket, Bullet, Asteroid, and Explosion

Exercise 1.10 Right Click on the Object

Exercise 1.10 Click on setGunReloadTime and Type 5

Exercise 1.11 Right Click on the Object and Select Inspect

Exercise 1.11 Right Click on the Object and Select Inspect

Exercise 1.12 Right Click on the Object and Select getSpeed ( )

Exercise 1.12

Exercise 1.13

Exercise 1.14 Right Click on the Object and Select setSize(int Size) and Set the Size to 256

1.10 Source Code Right Click on the Class and Select Open editor

Source Code for Rocket

Exercise 1.15 Change gunReloadTime from 20 to 5

Exercise 1.15

Class Changed Class Compiled

1.11 Summary In this chapter, we have seen what Greenfoot scenarios can look like and how to interact with them. We have seen how to create objects and how to communicate with these objects by invoking their methods. Some methods are commands to objects, while other methods return information about the object. Parameters are used to provide additional information to methods, while return values pass information back to the caller.

Concept Summary