001    package org.realobject;
002    
003    import java.awt.geom.*;
004    import org.util.*;
005    
006    public class Ball {
007    
008            private Point2D.Double location_;
009            private Point2D.Double velocity_;
010            private Point2D.Double force_;
011            private double radius_;
012            private double mass_;
013            
014            public Ball(Point2D.Double location, double radius, double mass) {
015                    location_ = location;
016                    radius_ = radius;
017                    mass_ = mass;
018                    velocity_ = new Point2D.Double(0, 0);
019                    force_ = new Point2D.Double(0, 0);
020            }
021            public void setLocation(Point2D.Double location) {
022                    location_ = location;
023            }
024            public void move(double dx, double dy) {
025                    location_.setLocation(location_.getX()+dx, location_.getY()+dy);
026            }
027    
028            public void setVelocity(double x, double y) {
029                    velocity_.setLocation(x, y);
030            }
031            public void setVelocity(Point2D.Double velocity) {
032                    velocity_ = velocity;
033            }
034            public Point2D.Double getVelocity() {
035                    return velocity_;
036            }
037            
038            public void setForce(Point2D.Double force) {
039                    force_ = force;
040            }
041            public Point2D.Double getForce() {
042                    return force_;
043            }
044            public void setForce(double x, double y) {
045                    force_.setLocation(x, y);
046            }
047            public void addForce(double dx, double dy) {
048                    force_.setLocation(force_.getX()+dx, force_.getY()+dy);
049            }
050            public Point2D.Double getLocation() {
051                    return location_;
052            }
053            public double getMass() {
054                    return mass_;
055            }
056            public double getRadius() {
057                    return radius_;
058            }
059            public String toString() {
060                    return "Ball";
061            }
062    }