Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

having a problem with the setpolygon statement in this code The method setPolygon(Point[]) in the type PolyBlob is not applicable for the arguments (int[], int[])

having a problem with the setpolygon statement in this code "The method setPolygon(Point[]) in the type PolyBlob is not applicable for the arguments (int[], int[])" need a fix full code for both classes used below

Asteroid.java

import java.util.Random;

public class Asteroid extends blobz.PolyBlob {

public Asteroid(int x, int y, double r) { super(-100, -100, r); this.setDelta(x, y); Random ran = new Random(); int rad = ran.nextInt(11); int ver = ran.nextInt(5) + 5; int[] xArr = new int[ver]; int[] yArr = new int[ver]; double arc = 360/ver; for(int i = 0; i < ver; i++) { double ang = (arc * i) + (ran.nextDouble() * arc ); double arcRad = (ran.nextInt(rad + 1) + 5); ang = Math.toRadians(ang); xArr[i] = (int)Math.round(Math.cos(ang) * arcRad); yArr[i] = (int)Math.round(Math.sin(ang) * arcRad); } this.setPolygon(xArr, yArr); } }

--------------------------------------------------------------------------------------------------------

asteroidfield.java

import blobz.*; import java.util.Random;

public class AsteroidField implements BlobGUI {

public static void main(String[] args) { new AsteroidField( Integer.parseInt( args[0])); } private final SandBox sandBox; public AsteroidField(int i) { sandBox = new SandBox(); sandBox.setSandBoxMode(SandBoxMode.FLOW); sandBox.setFrameRate(15); sandBox.init(this); }

public void generate() { Random ran = new Random(); for(int i = 0; i < 20; i++) { int x = (ran.nextInt(3) + 1) * (ran.nextBoolean() ? -1: 1); int y = (ran.nextInt(3) + 1) * (ran.nextBoolean() ? -1: 1); double r = ran.nextBoolean() ? -.1: .1; sandBox.addBlob(new Asteroid(x,y,r)); } } }

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

What is linear transformation? Define with example

Answered: 1 week ago

Question

The nature and importance of the global marketplace.

Answered: 1 week ago