2 Replies - 1953 Views - Last Post: 11 March 2005 - 07:36 PM Rate Topic: -----

#1 Ganospith  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 02-December 03

School Problem Help Please

Posted 11 March 2005 - 07:25 PM

This is the Draw Particle class I have written. The Iterator method has a problem also I have to write in my "For" loop how to draw particles that collide from radius 1 to radius 2.

Here is the assignment any hints or tips would be awesome, but I am really stuck so help please. I will also attach my two other classes that are imported. If your wondering what anything is please just ask I will be checking this forum alot tonight. I have to have this in by 5 PM tomorrow. Im not asking you to write the program, but point me in the right direction please. Here was the original assignment.


Watching Particles Collide
For this programming assignment, you are going to read in a set of particles and, using a graphics object, illustrate the collisions. To simplify things, only the first particle wll be moving.

The Input
The initial input will consist of particle descriptions. Each particle will be described by four double values: the particle's x-coordinate, the particle's y-coordinate, the x component of the particle's velocity, and the y-component of the particle's velocity. The first particle will have a nonzero velocity, all remaining particles will have a zero velocity (in both components). The end of the input will be indicated by a particle with a velocity of -1 in both components (this particle is not considered to be part of the simulation).

The Computation
Your job is to determine which particles the moving particle will collide with. We're going to make this very simple: when a moving particle collides with a stationary particle. The stationary particle gets bigger and the moving particle is unaffected (i.e., it keeps moving in the same direction and velocity). The computation ends, when there are no further collisions.

The Output
The output will consist of two parts. The output to theScreen should print the position of the collisions and the time at which they occur, ordered by the time of the collision. In addition to theScreen output, you should produce a graphical image of the collisions. In this image, you should draw a line that indicates the path taken by the moving particle and circles to indicate the position of the stationary particles. If a stationary particle is not involved in a collision, it should be drawn with a radius of 1; otherwise, it should be drawn with a radius of 2.

The Space class
The Space class is used to construct the image. This class provides a constructor and two methods: drawLine and drawCircle.

The constructor takes two double arguments: the maximum x-coordinate and the maximum y-coordinate -- for this exercise, you can use 100 and 100. As such, you can use the following code to construct an instance of the Space class:
mySpace = new Space( 100.0, 100.0 );

The drawLine method takes four double arguments which represent the two endpoints of the line segment. The folliowing call will draw a line between (2.5, 4.3) and (8.6, 20.9):
mySpace.drawLine( 2.5, 4.3, 8.6, 20.9 );

The drawCircle method takes three double arguments which represent the center and the radius of the circle. The following call will draw a circle with the center at (-34.6, 19.2) with radius 5.3:
mySpace.drawCircle( -34.6, 19.2, 5.3)

Notes
I will provide everything you need for the Space class in the next day or two.

Wednesday, I will cover the Vector class and how to iterate over all of the elements in a Vector.

I will provide a Particle class after 5pm on Saturday (the last day to turn in the current program).



THE FORUM WOULD NOT LET ME POST A .JAVA PROGRAM SO I COPIED IT TO WORD.

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: School Problem Help Please

#2 Ganospith  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 02-December 03

Re: School Problem Help Please

Posted 11 March 2005 - 07:29 PM

Here is the Particle Class we had to use it has a whenCollide method that tells the user when two particles collide.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#3 Ganospith  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 02-December 03

Re: School Problem Help Please

Posted 11 March 2005 - 07:36 PM

ann.easyio is the Screen and Keyboard class that they have us use so if you need to import somthing else to make it work feel free. Like I said before I am not looking for anyone to write the program for me I just need help debugging and if someone could point me in the right direction to drawing the particles that collide and what not. Thanks for your help. here is the webpage for my class.

My Computer Science Program Discription
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1