Question: JAVA thank you! Seprate to 3 files! 1.RandomStar.java 2.JFrame.java (provided) 3.RandomStarViewer.java(provided) Use the following files: JFrame.java RandomStarComponent.java import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JComponent; public class

JAVA thank you!

Seprate to 3 files!

1.RandomStar.java

2.JFrame.java (provided)

3.RandomStarViewer.java(provided)JAVA thank you! Seprate to 3 files! 1.RandomStar.java 2.JFrame.java (provided) 3.RandomStarViewer.java(provided) Use

Use the following files:

JFrame.java

 

RandomStarComponent.java

import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JComponent; public class RandomStarComponent extends JComponent { private static final long serialVersionUID = 1L; public void paintComponent(Graphics g) { // Recover Graphics2D Graphics2D g2 = (Graphics2D) g; RandomStar star = new RandomStar(100, 100, 50, 25); star.draw(g2); RandomStar star2 = new RandomStar(100, 200, 40, 60); star2.draw(g2); RandomStar star3 = new RandomStar(100, 300, 40, 30); star3.draw(g2); } } 

RandomStarViewer.java

import javax.swing.*; public class RandomStarViewer { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(300, 400); frame.setTitle("RandomStar"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); RandomStarComponent component = new RandomStarComponent(); frame.add(component); frame.setVisible(true); } }

Create a class RandomStar which models a star burst of random lines radiating in all directions from a given point. The constructor takes the x, y coordinates of the center of the star, the maximum distance of the x and y coordinates of the radiating lines from the center of the RandomStar, and the number of lines to draw. The draw method takes the graphical context as a parameter. It draws the specified number of lines. Each line has one end point at the center of the RandomStar. The other end has x and y coordinates each of which are less than the maximum distance specified from the center. Your output will look like this RandomStar Here is the starter flle for RandomStar. Use this Random object created with a seed so that your code will pase Codecheck public class RandomStar private Random gen; public RandomStar (int x, int y, int maxDistance, int numberOfLines) gen new Random (987654321) //... your code

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!