Question: Java & StdDraw - How can I draw a baseball (using filled white circles and red arcs on top of the cirlces) using this code?

Java & StdDraw - How can I draw a baseball (using filled white circles and red arcs on top of the cirlces) using this code? I'm having trouble getting the red arcs onto the cirlces with the offsets and what not. I have the gray circles so I can tell them apart. Very new at coding so I apologize...

import java.awt.Color;

import StdDraw;

public class ... {

/******************************************************************** * * Main program * * Set up the canvas, and draw several examples of the baseball. * ******************************************************************/ public static void main(String args[]) { // initialize canvas int width = 1000, height = 1000; StdDraw.setCanvasSize(width, height); StdDraw.clear(StdDraw.BLACK); // draw a black background // test circles manually at different scales StdDraw.setXscale(0, width/5); StdDraw.setYscale(0, height/5); drawBB(Color.WHITE);

// demonstrate offset StdDraw.setXscale(0, width/20); StdDraw.setYscale(0, height/20); drawBB(Color.WHITE,10,35); StdDraw.setXscale(0, width/10); StdDraw.setYscale(0, height/10); drawBB(Color.WHITE,75,35); // use for loops StdDraw.setXscale(0, width/2); StdDraw.setYscale(0, height/2); for (int i=0;i<7;i++) drawBB(Color.GRAY, 250+i*30,270); for (int i=0;i<5;i++) drawBB(Color.WHITE, 200+i*50,300); } /******************************************************************** * drawBB * * Main drawBB method. All other methods call this one. * ******************************************************************/ public static void drawBB(Color bodyColor, int offsetX, int offsetY) { StdDraw.setPenColor(bodyColor); StdDraw.filledCircle(8+offsetX,7+offsetY,5); } /******************************************************************** * Other drawBB methods * ******************************************************************/ public static void drawBB() { drawBB(Color.WHITE, 0, 0); } public static void drawBB(Color bodyColor) { drawBB(bodyColor, 0, 0); } public static void drawBB(int offsetX, int offsetY) { drawBB(Color.GRAY, offsetX, offsetY); }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!