Question: I need help returning the olympic rings. I did some of the code but I haven't had any luck returning a single ring. Instructions: Write

I need help returning the olympic rings. I did some of the code but I haven't had any luck returning a single ring.

Instructions: Write a program that displays the Olympic rings logo. Color the rings in the Olympic colors. Provide classes OlympicRing, OlympicRingViewer and OlympicRingComponent.

To set the lineWidth for the rings, you can use: int lineWidth=4; g2.setStroke(new BasicStroke(lineWidth));

It is not necessary to interlock the rings.

Code I did:

import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; import java.awt.Color;

public class Olympic { private int x; private int y; private int lineWidth; public Olympic(int x, int y, int lineWidth){ this.x=x; this.y=y; this.lineWidth = lineWidth; } public void draw(Graphics2D g2) { Ellipse2D.Double ring = new Ellipse2D.Double(x , y ,lineWidth, lineWidth); g2.setColor(Color.YELLOW); } }

import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JComponent;

public class OlympicComponent extends JComponent { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; Olympic ring1 = new Olympic(1, 0, 40);

ring1.draw(g2); } }

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!