<address id="zhpbl"></address>
<noframes id="zhpbl">
<address id="zhpbl"><form id="zhpbl"><th id="zhpbl"></th></form></address>

    <em id="zhpbl"></em>

      <address id="zhpbl"><th id="zhpbl"><progress id="zhpbl"></progress></th></address>
      更多精彩內容,歡迎關注:

      視頻號
      視頻號

      抖音
      抖音

      快手
      快手

      微博
      微博

      java rectangle

      文檔

      java rectangle

      javarectangle是一個“區域”類,它的最大作用就是定義一個矩形的區域。Rectangle指定坐標空間中的一個區域,通過坐標空間中Rectangle對象左上方的點 (x,y)、寬度和高度可以定義這個區域。
      推薦度:
      導讀javarectangle是一個“區域”類,它的最大作用就是定義一個矩形的區域。Rectangle指定坐標空間中的一個區域,通過坐標空間中Rectangle對象左上方的點 (x,y)、寬度和高度可以定義這個區域。

      ? ?

      java rectangle是什么?讓我們一起來了解一下吧!

      java rectangle是一個“區域”類,它的最大作用就是定義一個矩形的區域。Rectangle 指定坐標空間中的一個區域,通過坐標空間中Rectangle對象左上方的點 (x,y)、寬度和高度可以定義這個區域。

      其構造函數Rectangle(int x, int y, int width, int height)

      height?
      Rectangle?的高度。?
      width?
      Rectangle?的寬度。?
      x
      Rectangle?左上角的?X?坐標。?
      y?
      Rectangle?左上角的?Y?坐標。

      以下兩個是其比較常用的方法:

      boolean?contains(int?x,int?y)-->判定點(x,y)是否包含在指定區域內
      boolean?contains(int?x,int?y,int?width,int?height)-->判定指定區域是否在其指定區域內

      實戰操作,具體步驟如下:

      public?class?Rectangle?{
      ?private?double?height;
      ?private?double?width;
      ?private?String?color;
      ?public?double?getHeight()?{
      ??return?height;
      ?}
      ?public?void?setHeight(double?height)?{
      ??this.height?=?height;
      ?}
      ?public?double?getWidth()?{
      ??return?width;
      ?}
      ?public?void?setWidth(double?width)?{
      ??this.width?=?width;
      ?}
      ?public?String?getColor()?{
      ??return?color;
      ?}
      ?public?void?setColor(String?color)?{
      ??this.color?=?color;
      ?}
      ?public?Rectangle(double?width,double?height,String?color){
      ??this.setColor(color);
      ??this.setHeight(height);
      ??this.setWidth(width);
      ?}
      ?public?void?getArea(){
      ??double?area=0;
      ??area=this.height*this.width;
      ??System.out.println("矩形的面積為"+area);
      ?}
      ?public?String?toString(){
      ??String?recStr="矩形的高度:"+this.getHeight()+"寬度:"+this.getWidth()
      ??+"顏色:"+this.getColor();
      ??return?recStr;
      ?}
      ?/**
      ??*?測試函數
      ??*?@param?args
      ??*/
      ?public?static?void?main(String[]?args)?{
      ??Rectangle?rec=new?Rectangle(3,?4,?"紅色");
      ??rec.getArea();
      ??System.out.println(rec.toString());
      ?}
      }

      以上就是小編今天的分享了,希望可以幫助到大家。

      文檔

      java rectangle

      javarectangle是一個“區域”類,它的最大作用就是定義一個矩形的區域。Rectangle指定坐標空間中的一個區域,通過坐標空間中Rectangle對象左上方的點 (x,y)、寬度和高度可以定義這個區域。
      推薦度:
      為你推薦
      資訊專欄
      熱門視頻
      相關推薦
      java redirect java reference java reflect java regex java openssl java orm java outer java outofmemory java overload java resources java resolve java require java region java render java override java pandas java parse java repeat java parser java request java openjdk java opengl java openfire java onvif java inputstreamreader java influxdb java implements java image java htmlunit java hibernate java number java nslookup java notify java node類 java hdfs java hashcode java getbytes java geotools java nfs java nexus
      Top 少妇高潮太爽了在线视频