Results 1 to 10 of 10
  1. #1
    eliCanzee is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    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.

  2. #2
    markw8500's Avatar
    markw8500 is offline Senior Member
    Join Date
    Jul 2008
    Location
    Pennsylvania, USA
    Posts
    136
    Rep Power
    0

    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...

  3. #3
    2potatocakes is offline Member
    Join Date
    Sep 2008
    Posts
    43
    Rep Power
    0

    Default

    haha, I love newbies that come on here thinking we'll do their homework for them ;)

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    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.

  5. #5
    eliCanzee is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    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 .

  6. #6
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    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:

    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.

  7. #7
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    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

  8. #8
    eliCanzee is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    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.

  9. #9
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    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

  10. #10
    eliCanzee is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    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 :D

Similar Threads

  1. how to make voice calls using java.
    By mansoor in forum Advanced Java
    Replies: 3
    Last Post: 04-16-2009, 06:24 PM
  2. Would this be easy to make in java?
    By tooner in forum Java Applets
    Replies: 3
    Last Post: 03-20-2009, 05:55 PM
  3. Make java applet a button
    By hervey in forum New To Java
    Replies: 31
    Last Post: 10-30-2008, 05:44 AM
  4. How to make Java see a string as html
    By matpj in forum Java Applets
    Replies: 4
    Last Post: 09-26-2008, 03:40 AM
  5. Replies: 24
    Last Post: 07-29-2008, 04:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •