Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. package p;
  2. //2020-01-21
  3. import java.awt.*;
  4. import java.util.ArrayList;
  5.  
  6. public class Planet{
  7.  
  8. private double x,y;
  9. private double vx,vy;
  10. private double ax=0,ay=0;
  11. double mass; int radius; Color color;
  12.  
  13. public Planet(double x, double y, double vx, double vy, double mass, int radius, Color color) {
  14. this.x = x; this.y = y;
  15. this.vx = vx; this.vy = vy;
  16. this.mass = mass; this.radius = radius; this.color = color;
  17. }
  18.  
  19. void updatePosition(double dt) {
  20. this.x += this.vx * dt + (this.ax * Math.pow(dt, 2)/(2));
  21. this.y += this.vy * dt + (this.ay * Math.pow(dt, 2)/(2));
  22. }
  23.  
  24. void updateVelocity(double ax, double ay, double dt) {
  25. this.vx += ax * (dt/2);
  26. this.vy += ay * (dt/2);
  27. }
  28.  
  29. public double getX() {
  30. return x;
  31. }
  32.  
  33. public void setX(double x) {
  34. this.x = x;
  35. }
  36.  
  37. public double getY() {
  38. return y;
  39. }
  40.  
  41. public void setY(double y) {
  42. this.y = y;
  43. }
  44.  
  45. public void setVx(double vx) {
  46. this.vx = vx;
  47. }
  48.  
  49. public void setVy(double vy) {
  50. this.vy = vy;
  51. }
  52.  
  53. public double getMass() {
  54. return mass;
  55. }
  56.  
  57. public double getAx() {
  58. return ax;
  59. }
  60.  
  61. public void addAx(double ax) {
  62. this.ax += ax;
  63. }
  64.  
  65. public double getAy() {
  66. return ay;
  67. }
  68.  
  69. public void setAx(double ax) {
  70. this.ax = ax;
  71. }
  72.  
  73. public void setAy(double ay) {
  74. this.ay = ay;
  75. }
  76.  
  77. public void addAy(double ay) {
  78. this.ay += ay;
  79. }
  80.  
  81. public void setMass(double mass) {
  82. this.mass = mass;
  83. }
  84.  
  85. public int getRadius() {
  86. return radius;
  87. }
  88.  
  89. public void setRadius(int radius) {
  90. this.radius = radius;
  91. }
  92.  
  93. public Color getColor() {
  94. return color;
  95. }
  96.  
  97. public void setColor(Color color) {
  98. this.color = color;
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement