zoukankan      html  css  js  c++  java
  • Point

    public class Point {
    private double x;
    private double y;
    public Point(double x,double y){
    this.x=x;
    this.y=y;
    }
    public double radius(){
    return Math.sqrt(x*x+y*y);
    }
    public double angle(){
    return(180/3.14159)*Math.atan2(y, x);
    }
    public static void main(String[] args){
    Point p1=new Point(10,10);
    System.out.print("x="+p1.x+" ");
    System.out.print("y="+p1.y+" ");
    int i=(int)p1.angle();
    int j=(int)p1.radius();
    System.out.print("radius="+i+" ");
    System.out.print("angle="+j+" ");
    System.out.println();
    Point p2=new Point(15,18);
    i=(int)p2.angle();
    j=(int)p2.radius();
    System.out.print("x="+p2.x+" ");
    System.out.print("y="+p2.y+" ");
    System.out.print("radius="+i+" ");
    System.out.print("angle="+j+" ");
    }

    }

  • 相关阅读:
    简化单例模式
    static
    单例模式之懒汉模式
    Car race game
    poj-2403
    poj-2612
    poj-1833
    poj--2782
    poj--2608
    poj--3086
  • 原文地址:https://www.cnblogs.com/wlp1115/p/6560099.html
Copyright © 2011-2022 走看看