Guest User

Untitled

a guest
Dec 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. package cz.muni.fi.pb162.project.geometry;
  2.  
  3.  
  4. /**
  5. * Write a description of class Vertex2D here.
  6. *
  7. * @author (your name)
  8. * @version (a version number or a date)
  9. */
  10. public class Vertex2D
  11. {
  12. private double x;
  13. private double y;
  14.  
  15.  
  16. /**
  17. * An example of a method - replace this comment with your own
  18. *
  19. * @param y a sample parameter for a method
  20. * @return the sum of x and y
  21. */
  22. public double getX(){
  23. return x;
  24. }
  25.  
  26. public double getY(){
  27. return y;
  28. }
  29.  
  30. public void setX(double x){
  31. this.x=x;
  32. }
  33.  
  34. public void setY(double y){
  35. this.y=y;
  36. }
  37.  
  38. public String toString(){
  39. return "["+x+", "+y+"]";
  40. }
  41.  
  42. public double distance(Vertex2D point){
  43. double d;
  44. point.getX
  45.  
  46. d = Math.sqrt((x - y) * (x - y) + (y2 - y1) * (y2 - y1));
  47. return d;
  48. }
  49. }
  50.  
  51.  
  52.  
  53.  
  54. package cz.muni.fi.pb162.project.geometry;
  55.  
  56.  
  57. /**
  58. * Write a description of class Triangle here.
  59. *
  60. * @author (your name)
  61. * @version (a version number or a date)
  62. */
  63. public class Triangle
  64. {
  65. private Vertex2D a;
  66. private Vertex2D b;
  67. private Vertex2D c;
  68.  
  69. /**
  70. * An example of a method - replace this comment with your own
  71. *
  72. * @param y a sample parameter for a method
  73. * @return the sum of x and y
  74. */
  75. public void setVertexA(double x, double y){
  76.  
  77. a = vert;
  78. a.setX(x);
  79. a.setY(y);
  80.  
  81. }
  82.  
  83. public void setVertexB(double x, double y){
  84. b.setX(x);
  85. b.setX(x);
  86. }
  87.  
  88. public void setVertexC(double x, double y){
  89. c.setX(x);
  90. c.setX(x);
  91. }
  92.  
  93. public Vertex2D getVertexA(){
  94. return a;
  95.  
  96. }
  97.  
  98. public Vertex2D getVertexB(){
  99. return b;
  100.  
  101. }
  102.  
  103. public Vertex2D getVertexC(){
  104. return c;
  105.  
  106. }
  107.  
  108. public boolean isEquilateral(Vertex2D aa, Vertex2D bn){
  109. //if (Math.abs(b.distance(aa) - c.distance(bb) < 0.001))
  110. return true;
  111. }
  112.  
  113. public String toString(){
  114. return "Triangle: vertices=["+a.getX()+","+a.getY()+"] ["+b.getX()+", "+b.getY()+"] ["+c.getX()+", "+c.getY()+"].";
  115. }
  116. }
Add Comment
Please, Sign In to add comment