Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-29-2009, 06:22 PM
Member
 
Join Date: Apr 2009
Posts: 12
Rep Power: 0
eliCanzee is on a distinguished road
Post Can anybody make this on java ???
Can anybody make this on java ???
plss I nedd it for my exam ...
This is the text fot program :

Program an animation of a cannon ball shot into the air: The position, x,y,
of the cannon ball in the air after t seconds have elapsed is de?ned by these
formulas:
x = initial
velocitycosine(radians angle)t
2
velocitysine(radians angle)t)((gravityt )2)
y = (initial
where initial velocity is the velocity of the ball when it ?rst leaves the cannon,
gravity is the pull of gravity, and radians angle is computed as radians angle =
(degrees PI)180 degrees is the angle that the cannon was pointed when it
shot the cannon ball.
Your application should let the user experiment with di?erent initial velocities,
degrees angles, and gravitational constants.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 04-29-2009, 06:30 PM
markw8500's Avatar
Senior Member
 
Join Date: Jul 2008
Location: Pennsylvania, USA
Posts: 136
Rep Power: 0
markw8500 is on a distinguished road
Default
That sounds like a small challenge... But not impossible...

Get started and once you get stuck, post your questions...
__________________
Who Cares... As Long As It Works...
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-29-2009, 09:46 PM
Member
 
Join Date: Sep 2008
Posts: 43
Rep Power: 0
2potatocakes is on a distinguished road
Default
haha, I love newbies that come on here thinking we'll do their homework for them
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-29-2009, 10:42 PM
CJSLMAN's Avatar
Moderator
 
Join Date: Oct 2008
Location: Mexico
Posts: 1,159
Rep Power: 3
CJSLMAN is on a distinguished road
Default
Sorry, but this is not "Code-R-Us". If you have a specific question/problem, you will get a specific answer. You also have to show some effort, so....
On what part are you stuck on?

Luck,
CJSL
__________________
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-29-2009, 11:35 PM
Member
 
Join Date: Apr 2009
Posts: 12
Rep Power: 0
eliCanzee is on a distinguished road
Default
This is a question from david schmidt book chaprer 7.14 question number 15 ... but I don't know how to start has anybody ready this work :P .
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-29-2009, 11:49 PM
CJSLMAN's Avatar
Moderator
 
Join Date: Oct 2008
Location: Mexico
Posts: 1,159
Rep Power: 3
CJSLMAN is on a distinguished road
Default Start from the begining...
I'm not a GUI expert, so the GUI guys will have to jump in and help out...
  • First write down the requirements and understand them completely (do you understand the equations?)
  • Write down on paper the flow of your program and the different classes and methods that you will need.
  • One of those requirements is:
Quote:
Your application should let the user experiment with different initial velocities, degrees angles, and gravitational constants.
So start by getting the user's options (JOptionPane?)... are there any limits that these options should have? If so. you would also have to check for those limits.

Luck,
CJSL
__________________
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 04-30-2009, 12:22 AM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
Default
This is an exercise you have to do for your exam. If you don't know how to start try reading the rest of the book.
__________________
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 04-30-2009, 01:42 AM
Member
 
Join Date: Apr 2009
Posts: 12
Rep Power: 0
eliCanzee is on a distinguished road
Default
It's something like this :

FIGURE 14: view class for moving-ball simulation======================

import java.awt.*;
import javax.swing.*;
/** AnimationWriter displays a box with a ball in it. */
public class AnimationWriter extends JPanel
{ private BoxWriter box_writer; // the output-view of the box
private BallWriter ball_writer; // the output-view of the ball in the box

/** Constructor AnimationWriter constructs the view of box and ball
* @param b - the box's writer
* @param l - the ball's writer
* @param size - the frame's size */
public AnimationWriter(BoxWriter b, BallWriter l, int size)
{ box_writer = b;
ball_writer = l;
JFrame my_frame = new JFrame();
my_frame.getContentPane().add(this);
my_frame.setTitle("Bounce");
my_frame.setSize(size, size);
my_frame.setVisible(true);
}

/** paintComponent paints the box and ball
* @param g - the graphics pen */
public void paintComponent(Graphics g)
{ box_writer.paint(g);
ball_writer.paint(g);
}
}

ENDFIGURE========================================= =========

FIGURE 15: view classes for box and ball===========================

import java.awt.*;
/** BoxWriter displays a box */
public class BoxWriter
{ private Box box; // the (address of the) box object that is displayed

/** Constructor BoxWriter displays the box
* @param b - the box that is displayed */
public BoxWriter(Box b)
{ box = b; }

/** paint paints the box
* @param g - the graphics pen used to paint the box */
public void paint(Graphics g)
{ int size = box.sizeOf();
g.setColor(Color.white);
g.fillRect(0, 0, size, size);
g.setColor(Color.black);
g.drawRect(0, 0, size, size);
}
}

import java.awt.*;
/** BallWriter displays a moving ball */
public class BallWriter
{ private MovingBall ball; // the (address of the) ball object displayed
private Color balls_color; // the ball's color

/** Constructor BallWriter
* @param x - the ball to be displayed
* @param c - its color */
public BallWriter(MovingBall x, Color c)
{ ball = x;
balls_color = c;
}

/** paint paints the ball on the view
* @param g - the graphics pen used to paint the ball */
public void paint(Graphics g)
{ g.setColor(balls_color);
int radius = ball.radiusOf();
g.fillOval(ball.xPosition() - radius,
ball.yPosition() - radius, radius * 2, radius * 2);
}
}




but I have to do this :

Program an animation of a cannon ball shot into the air: The position, x,y, of the cannon ball in the air after t seconds have elapsed is defined by these formulas:

x = initial_velocity * cosine(radians_angle) * t

y = (initial_velocity * sine(radians_angle) * t)
- ( (gravity * t2) / 2 )

where initial_velocity is the velocity of the ball when it first leaves the cannon, gravity is the pull of gravity, and radians_angle is computed as

radians_angle = (degrees * PI) / 180

degrees is the angle that the cannon was pointed when it shot the cannon ball.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 04-30-2009, 01:45 AM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
Default
So do that then. What is your question?
__________________
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 04-30-2009, 02:14 AM
Member
 
Join Date: Apr 2009
Posts: 12
Rep Power: 0
eliCanzee is on a distinguished road
Default
Heyy thnx I finished it .. it was easy only to change the x and y position .. thnx a lot for your time and help
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make voice calls using java. mansoor Advanced Java 3 04-16-2009 07:24 PM
Would this be easy to make in java? tooner Java Applets 3 03-20-2009 06:55 PM
Make java applet a button hervey New To Java 31 10-30-2008 06:44 AM
How to make Java see a string as html matpj Java Applets 4 09-26-2008 04:40 AM
Is it possible to make this in Java? Challenging question. matt_well New To Java 24 07-29-2008 05:04 PM


All times are GMT +2. The time now is 06:34 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org