Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone pls help me with this Im really confused about how to even start that. Pls show me how to do so I can

Can someone pls help me with this Im really confused about how to even start that. Pls show me how to do so I can understand it
This is the task:
image text in transcribed
This is the the starViewer code:
image text in transcribed
2) Exercise 2: Write a program that draws three stars. Use classes, Star, StarComponent, and StarViewer. The steps are as follows: . Create two classes called Star, StarComponent. will need to import java.awt.Graphics2D in Star java and java.awt.Graphics in StarComponent.java; (Step 1: Star Class) Add a constructor and draw(Graphics2D g2) method in class Star to draw a star like shape using three lines. Two diagonal lines and one vertical line. . To draw the shape of star, use the methods in Point2D to represent two points on the line and then draw a line using Line2D class. Draw a vertical line, left diagonal line, and right diagonal line. (Step 2: StarComponent Class) In StarComponent class, override the paintCom- ponent of the JComponent class and create an instance of class Star with initial point and draw a star by calling the method draw method in Star clas. . Draw three Star objects and draw three different stars on the window using the class Hint: The StarComponent class has the following structure public class StarComponent extends JComponent ( public void paintComponent (Graphics g) f StarViewer available to you. The figure can be seen as in the last page of this Lab. Graphics2D g2-(Graphics2D) g Create first instance of class Star at (0,0)* * Create second instance of class Star at (220,0) */ * Create third instance of class Star at (150, 200) */ package Star_Graph; import javax.swing. JFrame public class StarViewer t public static void main(Stringll args) // TODO Auto-generated method stulb JFrame frame =new JFrame(); frame.setSize(450,450); frame. setTitle("Three Stars"): frame. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE): StarComponent component- new StarComponent); frame.add(component); frame. setVisible(true); veirst us ise se

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

I need an introduction on leadership and change management

Answered: 1 week ago