having problems duplacating

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pmpt89
    New Member
    • Nov 2006
    • 1

    #1

    having problems duplacating

    i was trying to create 2 semi circles but it just wont work here is the orginal code with 1 circle and 1 semi circle.... can someone please help

    import java.awt.*;
    import java.applet.*;

    public class Part0 extends Applet {

    private Location imageLocation;
    private Angles angles;
    private int semiDiameter;
    private int circleDiameter;
    private Color circleColor;
    private Color semiColor;
    private Location semiOffset;
    private Location circleOffset;
    private ColouredSemiCir cle semi;
    private ColouredCircle circle;

    public void init() {

    imageLocation = new Location(50, 100);
    semiOffset = new Location(0, 0);
    circleOffset = new Location(-30, 50);
    circleDiameter = 100;
    semiDiameter = 30;
    angles = new Angles(0, 180);
    circleColor = new Color(255, 125, 0);
    semiColor = new Color(125, 125, 125);
    // Using these, variables to create the body.
    circle = new ColouredCircle( circleDiameter, imageLocation, circleOffset,
    circleColor);
    semi = new ColouredSemiCir cle(semiDiamete r, imageLocation, semiOffset,
    angles, semiColor);
    }

    // Part of the applet not used in Part0.
    public void start() {
    }

    // Part of the applet not used in Part0.
    public void stop() {
    }

    // Part of the applet not used in Part0.
    public void destroy() {
    }

    /**
    * Display the shapes created in this Applet.
    */
    public void paint (Graphics g) {
    semi.paint(g);
    circle.paint(g) ;
    }
    }
    Last edited by pmpt89; Nov 12 '06, 10:05 PM. Reason: typo
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by pmpt89
    i was trying to create 2 semi circles but it just wont work here is the orginal code with 1 circle and 1 semi circle.... can someone please help

    import java.awt.*;
    import java.applet.*;

    public class Part0 extends Applet {

    private Location imageLocation;
    private Angles angles;
    private int semiDiameter;
    private int circleDiameter;
    private Color circleColor;
    private Color semiColor;
    private Location semiOffset;
    private Location circleOffset;
    private ColouredSemiCir cle semi;
    private ColouredCircle circle;

    public void init() {

    imageLocation = new Location(50, 100);
    semiOffset = new Location(0, 0);
    circleOffset = new Location(-30, 50);
    circleDiameter = 100;
    semiDiameter = 30;
    angles = new Angles(0, 180);
    circleColor = new Color(255, 125, 0);
    semiColor = new Color(125, 125, 125);
    // Using these, variables to create the body.
    circle = new ColouredCircle( circleDiameter, imageLocation, circleOffset,
    circleColor);
    semi = new ColouredSemiCir cle(semiDiamete r, imageLocation, semiOffset,
    angles, semiColor);
    }

    // Part of the applet not used in Part0.
    public void start() {
    }

    // Part of the applet not used in Part0.
    public void stop() {
    }

    // Part of the applet not used in Part0.
    public void destroy() {
    }

    /**
    * Display the shapes created in this Applet.
    */
    public void paint (Graphics g) {
    semi.paint(g);
    circle.paint(g) ;
    }
    }
    Your question is very vague. In the code you have created a semicircle object and a circle object

    Code:
     
    circle = new ColouredCircle(circleDiameter, imageLocation, circleOffset,
    circleColor); 
    semi = new ColouredSemiCircle(semiDiameter, imageLocation, semiOffset, 
    angles, semiColor);
    If you want to create 2 semicircles, you replace the creation of the circle by creation of another semicircle with the appropriate arguements.
    Did you try that and if you did what error did you get?

    Comment

    Working...