Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.daniel.pratica5;
- public class ponto2D {
- double x, y;
- double distance_pontos;
- public ponto2D(double coord_x, double coord_y){
- x = coord_x;
- y = coord_y;
- }
- public double distanciaentrepontos(ponto2D p) {
- distance_pontos = Math.sqrt((x - p.x)*(x - p.x) + (y - p.y)*(y - p.y));
- return distance_pontos;
- }
- public double distanciaaocentro() {
- ponto2D aux = new ponto2D(0,0);
- return distanciaentrepontos(aux);
- /* --------- ou
- distance_centro = Math.sqrt((x * x) + (y * y));
- return distance_centro; ------- */
- }
- public void somaCoord(double valor){
- this.x = x + valor;
- this.y = y + valor;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement