Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSS Prog Project 6.18

 
Bill James
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The book doesn't mention the Circle class. Yet I've been told it is required for the solution to draw the circles. Anyone have tips so that I can draw the 20 circles randomly and change the color of the overlapping ones.
Thankyou.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill,
Welcome to JavaRanch!
You followed our Naming Policy, so you must be very intelligent. It's nice to have you around.
For this assignment, what do you already understand and know how to do? What have you tried or thought of trying to solve the problem? Why?
From what I've understood you to explain, you don't really need to make use of a Circle class just to draw some circles (Graphics::drawArc can be used to do that.) But I wouldn't be surprised if the point of the assignment is to create and make use of a Circle class.
What part of the assignment is slowing you down or giving you problems?
If you're not familiar with generating random numbers, take a look at java.lang.Math.random and java.util.Random .
And, if you haven't already become familiar with it, do learn to reference and understand The Java 2 Standard Edition API Specification so as to learn and understand the standard Java libraries.
Good Luck.
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a thought ...

class Circle can extend java.awt.Point, just add the radius to the Circle constructor.

You can use Math.random() for x and y (as Dirk suggested) to move the circles around or you can move the point (the center of the circle) by a specific amount each time to make sure that they overlap.

and java.awt.Color for the colors
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic