Advertisement
Guest User

ponto2D

a guest
Oct 20th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package com.example.daniel.pratica5;
  2.  
  3. public class ponto2D {
  4. double x, y;
  5. double distance_pontos;
  6.  
  7.  
  8. public ponto2D(double coord_x, double coord_y){
  9. x = coord_x;
  10. y = coord_y;
  11. }
  12.  
  13. public double distanciaentrepontos(ponto2D p) {
  14. distance_pontos = Math.sqrt((x - p.x)*(x - p.x) + (y - p.y)*(y - p.y));
  15. return distance_pontos;
  16. }
  17.  
  18. public double distanciaaocentro() {
  19. ponto2D aux = new ponto2D(0,0);
  20. return distanciaentrepontos(aux);
  21. /* --------- ou
  22. distance_centro = Math.sqrt((x * x) + (y * y));
  23. return distance_centro; ------- */
  24. }
  25.  
  26. public void somaCoord(double valor){
  27. this.x = x + valor;
  28. this.y = y + valor;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement