第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JAVA編程定義一個點類。?

JAVA編程定義一個點類。?

素胚勾勒不出你 2019-05-27 19:03:33
JAVA編程定義一個點類。 
查看完整描述

3 回答

?
Qyouu

TA貢獻1786條經(jīng)驗 獲得超11個贊

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

public class Point {

     

    private double x;

     

    private double y;

     

    public Point(double x, double y) {

        super();

        this.x = x;

        this.y = y;

    }

 

    public double distance(Point point) {

        return Math.sqrt((point.x - this.x) * (point.x - this.x) + (point.y - this.y) * (point.y - this.y));

    }

     

    public Point move(double x, double y) {

        return new Point(this.x + x, this.y + y);

    }

     

    @Override

    public String toString() {

        // TODO Auto-generated method stub

        return "(" + x + ", " + y + ")";

    }

     

    public static void main(String[] args) {

        Point p1 = new Point(5, 6);

        Point p2 = new Point(-2, -9);

         

        System.out.println(p1.distance(p2));

        System.out.println(p1.move(11, -2));

    }

     

}


查看完整回答
反對 回復(fù) 2019-06-01
?
有只小跳蛙

TA貢獻1824條經(jīng)驗 獲得超8個贊

class Point{

      int x;

      int y;

      public Point(int x,int y){

          this.x = x;

          this.y = y;

      }

       

      public void move(){

      //要怎么移動。。。

      }

      public void test(){

      //要測試什么。。。

      }

}


查看完整回答
反對 回復(fù) 2019-06-01
  • 3 回答
  • 0 關(guān)注
  • 847 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號