SlideShare a Scribd company logo

Greenfoot - introduzione a Java giocando

R
ronchet
1 of 29
Download to read offline
Greenfoot
Una Introduzione a Java,
giocando

Marco Ronchetti
Università di Trento
Credits
      Questeslides sono basate sui tutorial di Greenfoot,
    raggiungibili qui:

    http://www.greenfoot.org/doc/tut-1




2
Prerequisiti
      Conosciamo    già alcune basi di programmazione:
        Concetto  di variabile
        Operazioni elementari
        Sintassi di un qualche linguaggio di
         programmazione
        Strutture di controllo di flusso (if, while, for…)




3
Installazione: 1) hai Java? (Win)
      Verifica   se sulla tua macchina c’è Java

      1.    Windows: “Run…”


      2.    Scrivi cmd




      3.    Scrivi java –version

      Se non da errore, hai java.
      La versione deve essere
      almeno 1.5!


4
Installazione: 1) hai Java? (Mac - Linux)
      Verifica    se sulla tua macchina c’è Java

      1.     -
                Mac: lancia Applicazioni/Utility/Terminale
                Linux: apri una shell (terminale)


      2.     Scrivi java –version

      Se non da errore, hai java.
      La versione deve essere
      almeno 1.5!


5
Installazione 2 – Verifica se hai il JDK
        Nel terminale, esegui javac
        Se da errore, hai il Java Runtime Environment e
         non il Java Development Kit




    Output simile a questo
    Se hai il JDK




6

Recommended

Video on line as replacement of traditional lectures
Video on line as replacement of traditional lecturesVideo on line as replacement of traditional lectures
Video on line as replacement of traditional lecturesronchet
 
Lectures On Demand: delivering traditional lectures over the web
Lectures On Demand: delivering traditional lectures over the webLectures On Demand: delivering traditional lectures over the web
Lectures On Demand: delivering traditional lectures over the webronchet
 
Programmare con javascript
Programmare con javascriptProgrammare con javascript
Programmare con javascriptronchet
 
Using Wikipedia as a reference for extracting semantic information
Using Wikipedia as a reference for extracting semantic informationUsing Wikipedia as a reference for extracting semantic information
Using Wikipedia as a reference for extracting semantic informationronchet
 
Web 2.0 E Oltre
Web 2.0 E OltreWeb 2.0 E Oltre
Web 2.0 E Oltreronchet
 
Seconda guerra mondiale in europa
Seconda guerra mondiale in europaSeconda guerra mondiale in europa
Seconda guerra mondiale in europaronchet
 
Practical Introduction to the Semantic Mediawiki
Practical Introduction to the Semantic MediawikiPractical Introduction to the Semantic Mediawiki
Practical Introduction to the Semantic Mediawikironchet
 
Introducing interactive whiteboards in the schools
Introducing interactive whiteboards in the schoolsIntroducing interactive whiteboards in the schools
Introducing interactive whiteboards in the schoolsronchet
 

More Related Content

Featured

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Greenfoot - introduzione a Java giocando

  • 1. Greenfoot Una Introduzione a Java, giocando Marco Ronchetti Università di Trento
  • 2. Credits   Questeslides sono basate sui tutorial di Greenfoot, raggiungibili qui: http://www.greenfoot.org/doc/tut-1 2
  • 3. Prerequisiti   Conosciamo già alcune basi di programmazione:   Concetto di variabile   Operazioni elementari   Sintassi di un qualche linguaggio di programmazione   Strutture di controllo di flusso (if, while, for…) 3
  • 4. Installazione: 1) hai Java? (Win)   Verifica se sulla tua macchina c’è Java 1.  Windows: “Run…” 2.  Scrivi cmd 3.  Scrivi java –version Se non da errore, hai java. La versione deve essere almeno 1.5! 4
  • 5. Installazione: 1) hai Java? (Mac - Linux)   Verifica se sulla tua macchina c’è Java 1.  -   Mac: lancia Applicazioni/Utility/Terminale   Linux: apri una shell (terminale) 2.  Scrivi java –version Se non da errore, hai java. La versione deve essere almeno 1.5! 5
  • 6. Installazione 2 – Verifica se hai il JDK   Nel terminale, esegui javac   Se da errore, hai il Java Runtime Environment e non il Java Development Kit Output simile a questo Se hai il JDK 6
  • 7. Installazione 3 – carica Java   Solo se la tua macchina non ha già il JDK:   Scarica e installa il Java Development Kit 7
  • 8. Installazione 4 – scarica Greenfoot Sempre dal sito http://www.greenfoot.org/download Scegli la versione adatta alla tua macchina Linux diversi da Ubuntu o Debian devono usare la versione Java 8
  • 9. Installazione 5 - alternativa   Solo per Windows: Installazione su chiavetta USB 9
  • 10. Il mondo di Greenfoot (World) 10
  • 11. Mettere degli oggetti nel mondo Wombat = Vombatide Click con il tasto destro 11
  • 12. Mettere degli oggetti nel mondo Impariamo il linguaggio Gli oggetti = OGGETTI Creare oggetti = ISTANZIARE I prototipi (gli stampini) = CLASSI 12
  • 13. Fare agire gli oggetti   Clicchiamo sul menu “act” di un Wombat   Proviamo a mettere una foglia davanti a un Wombat e facciamolo andare sopra la foglia 13
  • 14. Eseguire   Clicchiamo su run():   Equivale a fare act(); act(); act(); act(); … Ovvero a while (true) { act(); } 14
  • 15. Eseguire azioni Click con il tasto destro 15
  • 16. Eseguire azioni Impariamo il linguaggio Le azioni = METODI Eseguire un’azione= INVOCARE UN METODO 16
  • 17. Eseguire azioni Impariamo il linguaggio boolean = {true, false } int= {MIN, …, -3, -2, -1, 0, 1, 2, 3, …, MAX} 17
  • 18. Creare un nuovo mondo   bottone di reset => Crea un “mondo” nuovo 18
  • 19. Invocare un metodo del Mondo   Anche il mondo è un oggetto… Click con il tasto destro 19
  • 20. Caricare un nuovo scenario   Scarica un file e unzippalo, da http://www.greenfoot.org/tutorial-files/modern-crab.zip   Carica lo scenario in Greenfoot 20
  • 21. Caricare un nuovo scenario   Scarica un file e unzippalo, da http://www.greenfoot.org/tutorial-files/modern-crab.zip   Carica lo scenario in Greenfoot Impariamo il linguaggio Lo scenario = IL PROGRAMMA 21
  • 22. Aggiungiamo un oggetto, ed eseguiamo 22
  • 23. Usiamo l’editor public void act(){ move(4); } public void act(){ move(4); turn(3); } 23
  • 24. Usiamo l’editor Occhi alle parentesi! public void act(){ move(4); if (Greenfoot.isKeyDown(“left”)){ turn(-3); } if (Greenfoot.isKeyDown(“right”)){ turn(3); } } 24
  • 25. Il granchio mangia i vermi public void act(){ move(4); if (Greenfoot.isKeyDown(“left”)){ turn(-3); } if (Greenfoot.isKeyDown(“right”)){ turn(3); } Actor worm; worm=getOneObjectAtOffset(0,0,Actor.class); if (worm!=null) { World world; world=getWorld(); world.removeObject(worm); } } 25
  • 26. Ereditarietà   Crabis-a Actor   Worm is-a Actor Un Crab (granchio) è un Actor (attore) Esempi di generalizzazione-specializzazione: Studente is-a Persona Professore is-a Persona 26
  • 27. Ereditarietà class Persona { String name; Date dataDiNascita; } class Studente extends Persona { int matricola; } Studente x=new Studente(); x.name=“Marco”; x.matricola=123; 27
  • 28. Un’occhiata alla documentazione Click su “Actor” – “Open Documentation” Ci serve per scoprire quali metodi abbiamo a disposizione! 28
  • 29. Riepilogo di cosa abbiamo discusso in aula   Classi   Oggetti   istanza, istanziare   Metodi   Variabilidi istanza   Ereditarietà: superclasse e sottoclasse   Come accedere alla documentazione di Greenfoot   Come accedere alla documantazione di Java 29