© A+ Computer Science - www.apluscompsci.com GridWorld © A+ Computer Science - www.apluscompsci.com.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

GridWorld Case Study The Classes A Summary by Jim Mims.
GridWorld Case Study Part 1 Experiments to Observe Attributes and Behavior of Actors A Summary by Jim Mims.
GridWorld Case Study Part 3 GridWorld Classes and Interfaces A Summary by Jim Mims.
GridWorld Case Study Part 2 Bug Variations A Summary by Jim Mims.
GridWorld Case Study Part 4 Classes that Extend the Critter Interface A Summary by Jim Mims.
GridWorld Case Study Part 5 Grid Data Structures Not Tested on A Exam A Summary by Jim Mims.
© A+ Computer Science - if-else if-else if switch case © A+ Computer Science -
Building Java Programs Interactive Programs w/ Scanner What is a class? What is an object? What is the difference between primitive and object variables?
ABNIAC The following slide presentation is to acquaint the student with ABNIAC. The version used for presentation is the Java version, which can be found.
2.1 Synthetic Division 1 In previous sections, we used long division to divide a polynomial by a binomial. Review Example: Simplify We will now perform.
Critters A Study in Design Patterns. Design Patterns  Not specific algorithms or data structures  A general reusable solution to a common problem.
Location Class Gridworld. Location Class Encapsulates the coordinates for an actor’s position in a grid – Row and Column number Rows increase going down.
Using a different image than normal Multiple images for a class Controlling the mouse click Controlling the keys pressed Launching an input dialog box.
1 Foundations of Software Design Lecture 3: How Computers Work Marti Hearst Fall 2002.
CSE 113 Week 5 February , Announcements  Module 2 due 2/15  Exam 3 is on 2/15  Module 3 due 2/22  Exam 4 is on 2/25  Module 4 due 2/29.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
 Prof. Dr. M. H. Assal Introduction to Computer AS 26/10/2014.
11:15:01 Storage device. Computer memory Primary storage 11:15:01.
Session Objectives Object Types – Query, HTML Table Purpose of the Query and Explanation How to add a Query to a PTF Test Case 2 Session 5 - Query.
GridWorld Case Study1 Barbara Ericson Georgia Tech Jan 2008.
For more info visit at For more info visit at
Agenda Scope of variables Comparable interface Location class in GridWorld homework.
© A+ Computer Science - Row = 0 Column = 0.
How to do well on the AP CS Free Response Questions
© A+ Computer Science - A queue is a group of same-type values. Values are added to the back of a queue and removed from the front.
Copying and Pasting Formulas and Functions Copying and Pasting Formulas and Functions, Slide 1Copyright © 2004, Jim Schwab, University of Texas at Austin.
GridWorld Case Study Barbara Ericson March 24, 2007.
Example Consider the following class specification for a class that stores a bunch of characters. /* class invariant *this bunch contains one or more char.
© A+ Computer Science - Grid is an interface that details the behaviors expected of a grid. All its methods are abstract methods.
The GridWorld Case Study Program Section 1 - Overview of the Class Hierarchies Section 2 - The Actor Class Section 3 - The Rock and Flower Classes Section.
GridWorld Case Study The case study is a program that simulates actions and interactions of objects in a two- dimensional grid. During a single step of.
Chomp. How is the game played Human player goes first choose a square, all to the right and down are “eaten” computer takes a turn whoever is forced to.
Object Orientated Programming in Perl Simulated Models of Termites.
How to do well on the AP CS Free Response Questions
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
GridWorld.
Exposure Java 2013 APCS Edition
EGR 115 Introduction to Computing for Engineers
ECS 9/7/17.
GridWorld Part 4 Meet the Critters.
Agenda About Quiz ChameleonCritter class CrabCritter class homework.
Barbara Ericson Georgia Tech Jan 2008
office product key|
A+ Computer Science AP Review 2018 AP CS A EXAM
Multiple Choice -answer the easiest question 1st
اختر أي شخصية واجعلها تطير!
Section 8.7 The Consequences of Scope.
© A+ Computer Science - GridWorld © A+ Computer Science -
© A+ Computer Science - GridWorld © A+ Computer Science -
© A+ Computer Science - Arrays and Lists © A+ Computer Science -
A+ Computer Science METHODS.
Let’s Learn About Spreadsheets
GridWorld Part 4 Meet the Critters.
A+ Computer Science METHODS.
© A+ Computer Science - GridWorld The GridWorld case study provides a graphical environment where visual objects inhabit and interact.
© A+ Computer Science - GridWorld © A+ Computer Science -
GridWorld Case Study.
© A+ Computer Science - GridWorld © A+ Computer Science -
Agenda Dancing bug class Class vs object Comparable interface
Computer Science 10 & ICT 9 EXCEL
A+ Computer Science AP Review 2019 AP CS A EXAM
© A+ Computer Science - GridWorld © A+ Computer Science -
Presentation transcript:

© A+ Computer Science - www.apluscompsci.com GridWorld © A+ Computer Science - www.apluscompsci.com

Visit us at www.apluscompsci.com Full Curriculum Solutions Provided by A+ Computer Science Visit us at www.apluscompsci.com Full Curriculum Solutions M/C Review Question Banks Live Programming Problems Tons of great content! www.facebook.com/APlusComputerScience © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com What is GridWorld? Row = 0 Column = 0 A grid is a structure that has rows and columns. A spreadsheet is a grid. A checker board is a grid. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com What is GridWorld? cols rows A grid is a structure that has rows and columns. A grid is a structure that has rows and columns. A spreadsheet is a grid. A checker board is a grid. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com What is GridWorld? Row = 2 Column = 1 A grid is a structure that has rows and columns. A spreadsheet is a grid. A checker board is a grid. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com What is GridWorld? © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com GridWorld Classes © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com ActorWorld © A+ Computer Science - www.apluscompsci.com

frequently used methods © A+ Computer Science - www.apluscompsci.com ActorWorld frequently used methods Name Use ActorWorld() creates a new world using 10X10 grid ActorWorld(grid) creates a new world using grid add(loc, thang) add thang at spot loc show() makes the world visible import info.gridworld.actor.World; © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com ActorWorld ActorWorld earth = new ActorWorld(); earth.show(); ActorWorld is used to graphically display a grid of Actors. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com ActorWorld A reference variable stores the memory address of an object. ActorWorld earth = new ActorWorld(); A reference variable is used to store the location of an Object. In most situations, a reference stores the actual memory address of an Object. earth stores the location / memory address of a new ActorWorld object. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com ActorWorld ActorWorld earth = new ActorWorld(); earth 0xF5 0xF5 ActorWorld Object A reference variable is used to store the location of an Object. In most situations, a reference stores the actual memory address of an Object. earth stores the location / memory address of a new ActorWorld. earth stores the address of an ActorWorld © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com ActorWorld reference command / method earth.show(); earth is a reference to an ActorWorld. earth.show() calls the ActorWorld show method to show the grid of actors graphically. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com open gridworldone.java © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Location © A+ Computer Science - www.apluscompsci.com

frequently used methods © A+ Computer Science - www.apluscompsci.com Location frequently used methods Name Use Location(row, col) creates a new row,col Location getCol() gets the column value for this location getRow() gets the row value for this location Location is a class that stores row and column information. Location spot = new Location(4,5); spot has a row value of 4 and a column value of 5. import info.gridworld.grid.Location; © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Location Location locTwo = new Location(3,5); System.out.println(locTwo); Location locThree = new Location(2,9); System.out.println(locThree); OUTPUT (3, 5) (2, 9) Location is a class that stores row and column information. Location spot = new Location(4,5); spot has a row value of 4 and a column value of 5. The Location class stores row and column information. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Location reference variable Location theLoc = new Location(3,4); Location is a class which must be instantiated before it can be used. In other words, you must make a new Location if you want to use a Location. A reference must be used to store the location in memory of the Location object created. A row value and a column value must be passed as parameters to the Location constructor. theLoc is a reference that will store the location/memory address of newly created Location object. object instantiation © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com open locationone.java © A+ Computer Science - www.apluscompsci.com

Visit us at www.apluscompsci.com Full Curriculum Solutions Provided by A+ Computer Science Visit us at www.apluscompsci.com Full Curriculum Solutions M/C Review Question Banks Live Programming Problems Tons of great content! www.facebook.com/APlusComputerScience © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Actor © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Actor Actor is the basic object from which all other GridWorld actors will be built. Each of the new actors created will extend the original actor class. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Actor ActorWorld world = new ActorWorld(); Actor dude = new Actor(); Location loc = new Location(0,0); world.add(loc, dude); world.show(); The add method of class World receives a Location parameter and an Actor reference. The Actor reference is stored in the grid at the specified Location. The default color of an Actor is BLUE. ActorWorld world = new ActorWorld(); Actor dude = new Actor(); Location loc = new Location(0,0); world.add(loc, dude); world.show(); What happens if you click on the actor? © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Methods reference command / method world.add(loc, dude); World is the reference to an world. Add is a method that adds a reference at a particular location. The add method is called to tell world to add dude at location loc. Methods are used to tell an object what to do. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com open actorone.java © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Bug © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Bug Bug differs from actor in that a bug actually moves from cell to cell. A bug moves to the cell immediately in front if possible. If a move is not possible, the bug turns in 45 degree increments until it finds a spot to which it can move. Bug is a suped up Actor. Bug extends Actor. Bug has two constructors, one of which takes a Color parameter. Bug will move when its act method is called. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Bug ActorWorld world = new ActorWorld(); Bug dude = new Bug(); world.add(new Location(3,3), dude); world.show(); In this example, a default Bug is created. A default bug is red and facing NORTH. The bug moves NORTH until it reaches the top of the grid. The bug them turns in 45 degree increments until it finds an empty location to which to move. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com open bugone.java © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Critter © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Critter Critter differs from actor in that a critter moves around the grid and eats specific types of other actors. Critter randomly picks one of its valid adjacent empty locations and moves to that location. Critter is a suped up actor that moves around the grid and eats other actors. Critter will eat all neighbors that are not critters and not rocks. Critter randomly selects one of its valid empty adjacent locations. Critter moves to the new location. © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Critter ActorWorld world = new ActorWorld(); Critter thang = new Critter(); Location loc = new Location(1,1); world.add(loc, thang); world.show(); //shortcut version of the code above ActorWorld world = new ActorWorld(); world.add(new Location(1,1), new Critter()); world.show(); © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com open critterone.java © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com imports © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com imports Imports are used to tell Java where to find a class. import info.gridworld.grid.Location; import info.gridworld.actor.Rock; import info.gridworld.actor.Flower; import java.awt.Color; © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com open gridworldtwo.java © A+ Computer Science - www.apluscompsci.com

© A+ Computer Science - www.apluscompsci.com Start work on ActorBox © A+ Computer Science - www.apluscompsci.com

Visit us at www.apluscompsci.com Full Curriculum Solutions Provided by A+ Computer Science Visit us at www.apluscompsci.com Full Curriculum Solutions M/C Review Question Banks Live Programming Problems Tons of great content! www.facebook.com/APlusComputerScience © A+ Computer Science - www.apluscompsci.com