import greenfoot.*; import java.awt.Graphics; import java.awt.Color; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class MyWorld here. * * @author (your name) * @version (a version number or a date) */ public class MyWorld extends World { /** * Constructor for objects of class MyWorld. * */ private final int size = 0; public MyWorld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(900, 600, 1); prepare(); } public void drawYinYang(final Graphics graphics) { final Color colorSave = graphics.getColor(); graphics.setColor(Color.WHITE); // Use fillOval to draw a filled in circle graphics.fillOval(0, 0, size-1, size-1); graphics.setColor(Color.BLACK); // Use fillArc to draw part of a filled in circle graphics.fillArc(0, 0, size-1, size-1, 270, 180); graphics.fillOval(size/4, size/2, size/2, size/2); graphics.setColor(Color.WHITE); graphics.fillOval(size/4, 0, size/2, size/2); graphics.fillOval(7*size/16, 11*size/16, size/8, size/8); graphics.setColor(Color.BLACK); graphics.fillOval(7*size/16, 3*size/16, size/8, size/8); // Use drawOval to draw an empty circle for the outside border graphics.drawOval(0, 0, size-1, size-1); graphics.setColor(colorSave); } /** * Prepare the world for the start of the program. * That is: create the initial objects and add them to the world. */ private void prepare() { YinYang yinYang = new YinYang(); addObject(yinYang,200,200); } }