Question
In JAVA need to get this.setPolygon(xArr, yArr); working getting error Unresolved compilation problem: The method setPolygon(Point[]) in the type PolyBlob is not applicable for
In JAVA
need to get "this.setPolygon(xArr, yArr); " working getting error
Unresolved compilation problem: The method setPolygon(Point[]) in the type PolyBlob is not applicable for the arguments (int[], int[])
dropbox for the class files here,
https://www.dropbox.com/s/hjkv2fvi34z4ucm/AsteroidsTest.zip?dl=0
code below for both classes
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(); } private final SandBox sandBox; public AsteroidField() { 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
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