1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Playground here. * * @author (your name) * @version (a version number or a date) */ public class Playground extends World { Segment[] segments; private int maxSegmentNum = 10 ; /** * Constructor for objects of class Playground. * */ public Playground() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super ( 600 , 400 , 1 ); segments = new Segment[maxSegmentNum]; segments[ 0 ] = new Segment(); segments[ 1 ] = new Segment(); addObject(segments[ 0 ], 100 , 100 ); segments[ 0 ].setLocation(segments[ 0 ].getX()+ 20 , segments[ 0 ].getY()); } } |

