# Simulations Barb Ericson

Yüklə 449 b.
 tarix 24.12.2017 ölçüsü 449 b. #17032

• ## Understand that object-oriented programs are simulations

• of turtles
• of robots
• of card games
• of fish

• ## Seymour Papert at MIT in the 60s

• By teaching the computer to do something the kids are thinking about thinking
• Develop problem solving skills
• Learn by constructing and debugging something
• Learn by making mistakes and fixing them

• ## Classes created at Georgia Tech

• As part of a undergraduate class

• ## The turtle starts off facing north and in the center of the world by default

• World world1 = new World();
• Turtle turtle1 = new Turtle(world1);
• ## Turtles can move forward

• turtle1.forward(100);

• ## Turtles can turn

• Positive turns to right
• turtle1.turn(90);
• turtle1.forward(100);
• Negative turns to the left
• turtle1.turn(-90);
• turtle1.forward(50);

• ## Each turtle has a pen

• The default is to have the pen down to leave a trail
• You can pick it up:
• turtle1.penUp();
• turtle1.turn(-90);
• turtle1.forward(70);
• You can put it down again:
• turtle1.penDown();
• turtle1.forward(100);

• ## Turtles can move to a specific location

• turtle1.moveTo(400,10);
• ## Of course, you can create many turtles and move them all

• Run TurtleTest
• Creates 1000 turtles and puts them in an array of turtles. Has each turn by a random amount from 0 to 359 and go forward by 100

• ## Turtles won’t move completely out of the boundaries of the world

• World world2 = new World();
• Turtle turtle2 = new Turtle(world2);
• turtle2.forward(600);

• ## Objects don’t “tell” each other what to do

• They “ask” each other to do things

• Square
• Triangle
• Hexagon
• Circle
• Spiral

• ## Karel code is in karelpremeir0407

• I modified the directories to match the package name
• I also modified the constructor to be public

• ## Edit KarelMain.java to try things out

• World.setVisible(true); // not visible to start
• UrRobot karel = new UrRobot(1, 1, East, 0, Color.red); // create a robot at 1,1 facing east with 0 beepers and a red badge

• ## There are public domain card images available at

• http://www.waste.org/~oxymoron/files/cards
• ## Dr. Estell of Ohio Northern University has some card game projects at http://nifty.stanford.edu/2004/EstellCardGame/index.html

• CardAssingment.doc

• ## Alyce Brady of Kalamazoo College

• Page of resources
• http://max.cs.kzoo.edu/AP/MBS/index.html
• Aquarium Lab Series
• Review of basics and set-up for Marine Biology Case Study
• http://max.cs.kzoo.edu/patterns/JavaPatternLabs/AquariumLabSeries/index.shtml
• Minnow Project
• http://max.cs.kzoo.edu/AP/MBS/RelatedAssignments/Minnow/MinnowProj.html

• ## Object-oriented programs are simulations

• Consist of interacting objects who send each other messages
• Objects can refuse to do what you ask
• ## Objects belong to classes

• An object is an instance of a class
• Classes describe the data and operations that all objects of the class will have
• A class creates objects
• ## Objects are responsible

• They should control their data
• They each have their own copy of their data

Yüklə 449 b.

Dostları ilə paylaş:

Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2022
rəhbərliyinə müraciət

Ana səhifə