////////////////////////////////////////////////////////////////////////////// /** * * First code entered into Car class - 9/14 lecture * * */ ////////////////////////////////////////////////////////////////////////////// import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Car here. * * @author (your name) * @version (a version number or a date) */ public class Car extends Vehicle { /** * Act - do whatever the Car wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { turn(14); } } ////////////////////////////////////////////////////////////////////////////// /** * * Second code entered into Car class - 9/14 lecture * Original turn method call commented out - replaced with call to move() * */ ////////////////////////////////////////////////////////////////////////////// import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Car here. * * @author (your name) * @version (a version number or a date) */ public class Car extends Vehicle { /** * Act - do whatever the Car wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { //turn(14); move(); } } ////////////////////////////////////////////////////////////////////////////// /** * * Car class at the end of 9/16 lecture * Insertion of end of world test * Insertion of code for seeing other cars and reacting * */ ////////////////////////////////////////////////////////////////////////////// import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Car here. * * @author (your name) * @version (a version number or a date) */ public class Car extends Vehicle { /** * Act - do whatever the Car wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { //turn(14); if(atWorldEdge()) { turn(-75); } if(canSee(Car.class)) { turn(34); } move(); } } ////////////////////////////////////////////////////////////////////////////// /** * * Car class at the end of 9/18 lecture * Insertion of random turning behavior * Start of breaking actions out into separate methods * */ ////////////////////////////////////////////////////////////////////////////// import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Car here. * * @author (your name) * @version (a version number or a date) */ public class Car extends Vehicle { /** * Act - do whatever the Car wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { checkWorldEdge(); if(canSee(Car.class)) { turn(34); } if(Greenfoot.getRandomNumber(100) < 25) { turn(Greenfoot.getRandomNumber(13) - 6); } move(); } public void checkWorldEdge() { if( atWorldEdge() ) { turn(-75); } } }