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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started