SlideShare a Scribd company logo
Introduction To
                            Greenfoot
                               Part-2


kakihijau.googlepages.com
Disclaimer
๏ƒ˜ This document is intended to give a beginner an introductory
  material for the Greenfoot system. Greenfoot is a software
  framework made by Poul Henriksen and Michael Koelling at
  University of Kent / Deakin University. More information can be
  found at http://www.greenfoot.org

๏ƒ˜ This document is available โ€žAS ISโ€œ free of charge for personal use
  and non-commercial redistribution. It may not be sold for profit or
  included in other packages which are sold for profit without written
  authorisation. This document is distributed in the hope that it will
  be useful, but WITHOUT ANY WARRANTY; your use of the
  document is at your sole risk. Reusing and modifying (part of) this
  document is allowed, as long as you state explicitly that your work is
  based on the original document produced by the copyright holder:
  Eueung Mulyana. The author can be contacted via
  eueung-[at]-yahoo.com (http://kakihijau.googlepages.com).


                                                     Introduction to Greenfoot              2
                                               Eueung Mulyana | kakihijau.googlepages.com
Purpose
๏ƒ˜ This is the second part of the document โ€žIntroduction to
  Greenfootโ€œ and focuses on understanding the wombats
  scenario

๏ƒ˜ Part of the content of these slides is based on the
  Greenfoot Tutorial made by Michael Koelling,
  publicly accesible at the Greenfoot website,
  http://www.greenfoot.org




                                              Introduction to Greenfoot              3
                                        Eueung Mulyana | kakihijau.googlepages.com
Outline
๏ƒ˜   Class Display Revisited
๏ƒ˜   Class Editor
๏ƒ˜   The Leaf Class
๏ƒ˜   The Wombat Class
๏ƒ˜   The WombatWorld Class




                                       Introduction to Greenfoot              4
                                 Eueung Mulyana | kakihijau.googlepages.com
Class Display Revisited




๏ƒ˜ Class display contains all classes which are used in a scenario
๏ƒ˜ Class World and Actor are abstract superclasses, part of the
  Greenfoot system
๏ƒ˜ Scenario wombats has 2 actor classes (Wombat, Leaf)

                                                      Introduction to Greenfoot              5
                                                Eueung Mulyana | kakihijau.googlepages.com
Class Editor (1)
๏ƒ˜ We can modify objects behaviour by
  editing the source code of the
  corresponding class

๏ƒ˜ To display the source code editor:
   โ€“ Double-click the class
   โ€“ Right-click the class, choose the item
     โ€žOpen editorโ€œ




                                                    Introduction to Greenfoot              6
                                              Eueung Mulyana | kakihijau.googlepages.com
Class Editor (2)




                   Introduction to Greenfoot              7
             Eueung Mulyana | kakihijau.googlepages.com
The Leaf Class
๏ƒ˜ The simplest class compared to the Wombat and
  WombatWorld class
๏ƒ˜ Leaf objects do nothing!
๏ƒ˜ As you can see in the previous slide, the Leaf class has no
  statement and consists of an empty constructor




                                              Introduction to Greenfoot              8
                                        Eueung Mulyana | kakihijau.googlepages.com
The Wombat Class (1)
import necessary packages




class header;
Wombat is a subclass
from Actor




data (constants and
variables)




class constructor and
methods


                                   Introduction to Greenfoot              9
                             Eueung Mulyana | kakihijau.googlepages.com
The Wombat Class (2)
๏ƒ˜ 4 constants : EAST, WEST,
  NORTH, SOUTH
๏ƒ˜ 2 variables : direction,
  leavesEaten
๏ƒ˜ 1 constructor : Wombat()
๏ƒ˜ 8 methods :
  โ€“ getLeavesEaten(), foundLeaf(),
    eatLeaf()
  โ€“ setDirection(), turnLeft()
  โ€“ canMove(), move()
  โ€“ act()



                                           Introduction to Greenfoot              10
                                     Eueung Mulyana | kakihijau.googlepages.com
The Wombat Class (3)

                           constructor ๏ƒ  initialising
                           direction and leavesEaten




is there any Leaf object
in my position?            this method is inherited from
                           the superclass Actor




remove that Leaf object
update the variable
leavesEaten



                                  Introduction to Greenfoot              11
                            Eueung Mulyana | kakihijau.googlepages.com
The Wombat Class (4)




                    Introduction to Greenfoot              12
              Eueung Mulyana | kakihijau.googlepages.com
The Wombat Class (5)



              this method is inherited from
              the superclass Actor




                     Introduction to Greenfoot              13
               Eueung Mulyana | kakihijau.googlepages.com
The Wombat Class (6)


         change direction 90 degrees
         to the left




                             Introduction to Greenfoot              14
                       Eueung Mulyana | kakihijau.googlepages.com
The Wombat Class (7)

                                 these methods are
                                 inherited from Actor
new coordinate
if the object moves
forward;
depends on
its direction




                              checks if the object
                              reaches the edges of the world




                                   Introduction to Greenfoot              15
                             Eueung Mulyana | kakihijau.googlepages.com
The Wombat Class (8)




                    Introduction to Greenfoot              16
              Eueung Mulyana | kakihijau.googlepages.com
The Wombat Class (9)
                            if object reaches one of
                            the borders, do nothing!




the object moves                            setLocation() is
forward;                                    inherited from Actor
depends on
its direction




                                     Introduction to Greenfoot              17
                               Eueung Mulyana | kakihijau.googlepages.com
The Wombat Class (10)



               if you find leaves, eat !

               if you donโ€˜t find leaves, but you
               can move forward, then move!

               if you donโ€˜t find leaves and you
               also cannot move, then turn to
               the left!




                     Introduction to Greenfoot              18
               Eueung Mulyana | kakihijau.googlepages.com
The WombatWorld Class (1)
๏ƒ˜ 1 constructor : WombatWorld()
๏ƒ˜ 2 methods :
   โ€“ populate()
   โ€“ randomLeaves()




                                        Introduction to Greenfoot              19
                                  Eueung Mulyana | kakihijau.googlepages.com
The WombatWorld Class (2)


                                 calls the World constructor




           sets the background.
           the method is inherited
           from the superclass World
                                                      cell.jpg




                                Introduction to Greenfoot              20
                          Eueung Mulyana | kakihijau.googlepages.com
The WombatWorld Class (3)




                       Introduction to Greenfoot              21
                 Eueung Mulyana | kakihijau.googlepages.com
The WombatWorld Class (4)


               Create a Leaf object at a random
               position (x,y); repeat howmany
               times




                          Introduction to Greenfoot              22
                    Eueung Mulyana | kakihijau.googlepages.com

More Related Content

More from Eueung Mulyana

ONOS SDN Controller - Clustering Tests & Experiments
ONOS SDN Controller - Clustering Tests & Experiments ONOS SDN Controller - Clustering Tests & Experiments
ONOS SDN Controller - Clustering Tests & Experiments
Eueung Mulyana
ย 
Open stack pike-devstack-tutorial
Open stack pike-devstack-tutorialOpen stack pike-devstack-tutorial
Open stack pike-devstack-tutorial
Eueung Mulyana
ย 
Basic onos-tutorial
Basic onos-tutorialBasic onos-tutorial
Basic onos-tutorial
Eueung Mulyana
ย 
ONOS SDN Controller - Introduction
ONOS SDN Controller - IntroductionONOS SDN Controller - Introduction
ONOS SDN Controller - Introduction
Eueung Mulyana
ย 
OpenDaylight SDN Controller - Introduction
OpenDaylight SDN Controller - IntroductionOpenDaylight SDN Controller - Introduction
OpenDaylight SDN Controller - Introduction
Eueung Mulyana
ย 
Mininet Basics
Mininet BasicsMininet Basics
Mininet Basics
Eueung Mulyana
ย 
Android Programming Basics
Android Programming BasicsAndroid Programming Basics
Android Programming Basics
Eueung Mulyana
ย 
Cloud Computing: Overview and Examples
Cloud Computing: Overview and ExamplesCloud Computing: Overview and Examples
Cloud Computing: Overview and Examples
Eueung Mulyana
ย 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuators
Eueung Mulyana
ย 
Connected Things, IoT and 5G
Connected Things, IoT and 5GConnected Things, IoT and 5G
Connected Things, IoT and 5G
Eueung Mulyana
ย 
Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+
Eueung Mulyana
ย 
NodeMCU with Blynk and Firebase
NodeMCU with Blynk and FirebaseNodeMCU with Blynk and Firebase
NodeMCU with Blynk and Firebase
Eueung Mulyana
ย 
Trends and Enablers - Connected Services and Cloud Computing
Trends and Enablers  - Connected Services and Cloud ComputingTrends and Enablers  - Connected Services and Cloud Computing
Trends and Enablers - Connected Services and Cloud Computing
Eueung Mulyana
ย 
Digital Ecosystems - Connected Services and Cloud Computing
Digital Ecosystems - Connected Services and Cloud ComputingDigital Ecosystems - Connected Services and Cloud Computing
Digital Ecosystems - Connected Services and Cloud Computing
Eueung Mulyana
ย 
Services Convergence - Connected Services and Cloud Computing
Services Convergence - Connected Services and Cloud ComputingServices Convergence - Connected Services and Cloud Computing
Services Convergence - Connected Services and Cloud Computing
Eueung Mulyana
ย 
Models and Architecture - Connected Services and Cloud Computing
Models and Architecture - Connected Services and Cloud ComputingModels and Architecture - Connected Services and Cloud Computing
Models and Architecture - Connected Services and Cloud Computing
Eueung Mulyana
ย 
Introduction, Examples - Firebase
Introduction, Examples - Firebase Introduction, Examples - Firebase
Introduction, Examples - Firebase
Eueung Mulyana
ย 
Vue js and Vue Material
Vue js and Vue MaterialVue js and Vue Material
Vue js and Vue Material
Eueung Mulyana
ย 
React Example + Bootstrap
React Example + BootstrapReact Example + Bootstrap
React Example + Bootstrap
Eueung Mulyana
ย 
introduction to material design lite MDL
introduction to material design lite MDLintroduction to material design lite MDL
introduction to material design lite MDL
Eueung Mulyana
ย 

More from Eueung Mulyana (20)

ONOS SDN Controller - Clustering Tests & Experiments
ONOS SDN Controller - Clustering Tests & Experiments ONOS SDN Controller - Clustering Tests & Experiments
ONOS SDN Controller - Clustering Tests & Experiments
ย 
Open stack pike-devstack-tutorial
Open stack pike-devstack-tutorialOpen stack pike-devstack-tutorial
Open stack pike-devstack-tutorial
ย 
Basic onos-tutorial
Basic onos-tutorialBasic onos-tutorial
Basic onos-tutorial
ย 
ONOS SDN Controller - Introduction
ONOS SDN Controller - IntroductionONOS SDN Controller - Introduction
ONOS SDN Controller - Introduction
ย 
OpenDaylight SDN Controller - Introduction
OpenDaylight SDN Controller - IntroductionOpenDaylight SDN Controller - Introduction
OpenDaylight SDN Controller - Introduction
ย 
Mininet Basics
Mininet BasicsMininet Basics
Mininet Basics
ย 
Android Programming Basics
Android Programming BasicsAndroid Programming Basics
Android Programming Basics
ย 
Cloud Computing: Overview and Examples
Cloud Computing: Overview and ExamplesCloud Computing: Overview and Examples
Cloud Computing: Overview and Examples
ย 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuators
ย 
Connected Things, IoT and 5G
Connected Things, IoT and 5GConnected Things, IoT and 5G
Connected Things, IoT and 5G
ย 
Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+Connectivity for Local Sensors and Actuators Using nRF24L01+
Connectivity for Local Sensors and Actuators Using nRF24L01+
ย 
NodeMCU with Blynk and Firebase
NodeMCU with Blynk and FirebaseNodeMCU with Blynk and Firebase
NodeMCU with Blynk and Firebase
ย 
Trends and Enablers - Connected Services and Cloud Computing
Trends and Enablers  - Connected Services and Cloud ComputingTrends and Enablers  - Connected Services and Cloud Computing
Trends and Enablers - Connected Services and Cloud Computing
ย 
Digital Ecosystems - Connected Services and Cloud Computing
Digital Ecosystems - Connected Services and Cloud ComputingDigital Ecosystems - Connected Services and Cloud Computing
Digital Ecosystems - Connected Services and Cloud Computing
ย 
Services Convergence - Connected Services and Cloud Computing
Services Convergence - Connected Services and Cloud ComputingServices Convergence - Connected Services and Cloud Computing
Services Convergence - Connected Services and Cloud Computing
ย 
Models and Architecture - Connected Services and Cloud Computing
Models and Architecture - Connected Services and Cloud ComputingModels and Architecture - Connected Services and Cloud Computing
Models and Architecture - Connected Services and Cloud Computing
ย 
Introduction, Examples - Firebase
Introduction, Examples - Firebase Introduction, Examples - Firebase
Introduction, Examples - Firebase
ย 
Vue js and Vue Material
Vue js and Vue MaterialVue js and Vue Material
Vue js and Vue Material
ย 
React Example + Bootstrap
React Example + BootstrapReact Example + Bootstrap
React Example + Bootstrap
ย 
introduction to material design lite MDL
introduction to material design lite MDLintroduction to material design lite MDL
introduction to material design lite MDL
ย 

Recently uploaded

Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Vivekanand Anglo Vedic Academy
ย 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
ย 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
ย 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
ย 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
ย 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
ย 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
ย 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
ย 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
ย 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
ย 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
ย 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
heathfieldcps1
ย 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
ย 
How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17
Celine George
ย 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
ย 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
ย 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
ย 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
ย 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
ย 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
ย 

Recently uploaded (20)

Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
ย 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
ย 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
ย 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
ย 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
ย 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
ย 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
ย 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
ย 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
ย 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
ย 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
ย 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
ย 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
ย 
How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17
ย 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
ย 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
ย 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
ย 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
ย 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
ย 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
ย 

Greenfoot Introduction (2)

  • 1. Introduction To Greenfoot Part-2 kakihijau.googlepages.com
  • 2. Disclaimer ๏ƒ˜ This document is intended to give a beginner an introductory material for the Greenfoot system. Greenfoot is a software framework made by Poul Henriksen and Michael Koelling at University of Kent / Deakin University. More information can be found at http://www.greenfoot.org ๏ƒ˜ This document is available โ€žAS ISโ€œ free of charge for personal use and non-commercial redistribution. It may not be sold for profit or included in other packages which are sold for profit without written authorisation. This document is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; your use of the document is at your sole risk. Reusing and modifying (part of) this document is allowed, as long as you state explicitly that your work is based on the original document produced by the copyright holder: Eueung Mulyana. The author can be contacted via eueung-[at]-yahoo.com (http://kakihijau.googlepages.com). Introduction to Greenfoot 2 Eueung Mulyana | kakihijau.googlepages.com
  • 3. Purpose ๏ƒ˜ This is the second part of the document โ€žIntroduction to Greenfootโ€œ and focuses on understanding the wombats scenario ๏ƒ˜ Part of the content of these slides is based on the Greenfoot Tutorial made by Michael Koelling, publicly accesible at the Greenfoot website, http://www.greenfoot.org Introduction to Greenfoot 3 Eueung Mulyana | kakihijau.googlepages.com
  • 4. Outline ๏ƒ˜ Class Display Revisited ๏ƒ˜ Class Editor ๏ƒ˜ The Leaf Class ๏ƒ˜ The Wombat Class ๏ƒ˜ The WombatWorld Class Introduction to Greenfoot 4 Eueung Mulyana | kakihijau.googlepages.com
  • 5. Class Display Revisited ๏ƒ˜ Class display contains all classes which are used in a scenario ๏ƒ˜ Class World and Actor are abstract superclasses, part of the Greenfoot system ๏ƒ˜ Scenario wombats has 2 actor classes (Wombat, Leaf) Introduction to Greenfoot 5 Eueung Mulyana | kakihijau.googlepages.com
  • 6. Class Editor (1) ๏ƒ˜ We can modify objects behaviour by editing the source code of the corresponding class ๏ƒ˜ To display the source code editor: โ€“ Double-click the class โ€“ Right-click the class, choose the item โ€žOpen editorโ€œ Introduction to Greenfoot 6 Eueung Mulyana | kakihijau.googlepages.com
  • 7. Class Editor (2) Introduction to Greenfoot 7 Eueung Mulyana | kakihijau.googlepages.com
  • 8. The Leaf Class ๏ƒ˜ The simplest class compared to the Wombat and WombatWorld class ๏ƒ˜ Leaf objects do nothing! ๏ƒ˜ As you can see in the previous slide, the Leaf class has no statement and consists of an empty constructor Introduction to Greenfoot 8 Eueung Mulyana | kakihijau.googlepages.com
  • 9. The Wombat Class (1) import necessary packages class header; Wombat is a subclass from Actor data (constants and variables) class constructor and methods Introduction to Greenfoot 9 Eueung Mulyana | kakihijau.googlepages.com
  • 10. The Wombat Class (2) ๏ƒ˜ 4 constants : EAST, WEST, NORTH, SOUTH ๏ƒ˜ 2 variables : direction, leavesEaten ๏ƒ˜ 1 constructor : Wombat() ๏ƒ˜ 8 methods : โ€“ getLeavesEaten(), foundLeaf(), eatLeaf() โ€“ setDirection(), turnLeft() โ€“ canMove(), move() โ€“ act() Introduction to Greenfoot 10 Eueung Mulyana | kakihijau.googlepages.com
  • 11. The Wombat Class (3) constructor ๏ƒ  initialising direction and leavesEaten is there any Leaf object in my position? this method is inherited from the superclass Actor remove that Leaf object update the variable leavesEaten Introduction to Greenfoot 11 Eueung Mulyana | kakihijau.googlepages.com
  • 12. The Wombat Class (4) Introduction to Greenfoot 12 Eueung Mulyana | kakihijau.googlepages.com
  • 13. The Wombat Class (5) this method is inherited from the superclass Actor Introduction to Greenfoot 13 Eueung Mulyana | kakihijau.googlepages.com
  • 14. The Wombat Class (6) change direction 90 degrees to the left Introduction to Greenfoot 14 Eueung Mulyana | kakihijau.googlepages.com
  • 15. The Wombat Class (7) these methods are inherited from Actor new coordinate if the object moves forward; depends on its direction checks if the object reaches the edges of the world Introduction to Greenfoot 15 Eueung Mulyana | kakihijau.googlepages.com
  • 16. The Wombat Class (8) Introduction to Greenfoot 16 Eueung Mulyana | kakihijau.googlepages.com
  • 17. The Wombat Class (9) if object reaches one of the borders, do nothing! the object moves setLocation() is forward; inherited from Actor depends on its direction Introduction to Greenfoot 17 Eueung Mulyana | kakihijau.googlepages.com
  • 18. The Wombat Class (10) if you find leaves, eat ! if you donโ€˜t find leaves, but you can move forward, then move! if you donโ€˜t find leaves and you also cannot move, then turn to the left! Introduction to Greenfoot 18 Eueung Mulyana | kakihijau.googlepages.com
  • 19. The WombatWorld Class (1) ๏ƒ˜ 1 constructor : WombatWorld() ๏ƒ˜ 2 methods : โ€“ populate() โ€“ randomLeaves() Introduction to Greenfoot 19 Eueung Mulyana | kakihijau.googlepages.com
  • 20. The WombatWorld Class (2) calls the World constructor sets the background. the method is inherited from the superclass World cell.jpg Introduction to Greenfoot 20 Eueung Mulyana | kakihijau.googlepages.com
  • 21. The WombatWorld Class (3) Introduction to Greenfoot 21 Eueung Mulyana | kakihijau.googlepages.com
  • 22. The WombatWorld Class (4) Create a Leaf object at a random position (x,y); repeat howmany times Introduction to Greenfoot 22 Eueung Mulyana | kakihijau.googlepages.com