<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      一、定義一個點(diǎn)類Point,包含2個成員變量x、y分別表示x和y坐標(biāo),2個構(gòu)造器Point()和Point(intx0,y0),以及一個movePoint(intdx,intdy)方法實(shí)現(xiàn)點(diǎn)的位置移動,創(chuàng)建兩個Point對象p1、p2,分別調(diào)用movePoint方法后,打印p1和p2的坐標(biāo)。[必作題]

      package abc;

      public class Point {

      int x;

      int y;

      public Point(int x0, int y0) {

      super();

      this.x = x0;

      this.y = y0;

      }

      public Point() {

      super();

      }

      public String movePoint(int dx, int dy) {

      x = dx + x;

      y = dy + y;

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

      }

      public static void main(String[] args) {

      // TODO Auto-generated method stub

       Point p1 = new Point(5,8);

      System.out.println(p1.movePoint(6, 9));

      Point p2 = new Point(2, 3);

      System.out.println(p2.movePoint(5, 7));

      }

       

       

      二、定義一個矩形類Rectangle:(知識點(diǎn):對象的創(chuàng)建和使用)[必做題]
      1.定義三個方法:getArea()求面積、getPer()求周長,showAll()分別在控制臺輸出長、寬、面積、周長。
      2.有2個屬性:長length、寬width
      3.通過構(gòu)造方法Rectangle(intwidth,intlength),分別給兩個屬性賦值
      4.創(chuàng)建一個Rectangle對象,并輸出相關(guān)信息

      package abc;

       

      public class Rectangle {

      int length,width;

      public int getArea(int length,int width){

      return length*width;

      }

      public int getPer(int length,int width){

      return (length+width)*2;

      }

      public  void showAll(){

      System.out.println("長方形的長是"+length+"寬是"+width);

      System.out.println("周長是"+ (length+width)*2);

      System.out.println("面積是"+length*width);

      }

      public Rectangle(int length, int width) {

      this.length = length;

      this.width = width;

      }

      public static void main(String[] args) {

              // TODO Auto-generated method stub

              Rectangle r=new Rectangle(15, 10);

              r.showAll();    

       

          }

      }

       

       

      三、定義一個筆記本類,該類有顏色(char)和cpu型號(int)兩個屬性。[必做題]
      1.無參和有參的兩個構(gòu)造方法;有參構(gòu)造方法可以在創(chuàng)建對象的同時(shí)為每個屬性賦值;
      2.輸出筆記本信息的方法
      3.然后編寫一個測試類,測試筆記本類的各個方法。

      package abc;

      public class computer {

      char colour;

      int cpu;

      public void show() {

      System.out.println("我的顏色是:" + colour+"色" + ",型號是:" + cpu);

      }

      public computer(char colour, int cpu) {

      super();

      this.colour = colour;

      this.cpu = cpu;

      }

      public computer() {

      super();

      }

      public static void main(String[] args) {

      // TODO Auto-generated method stub

      computer s1=new computer();

      s1.colour='黑';

               s1.cpu=121;

               s1.show();

               computer s2=new computer('藍(lán)',111);

               s2.show();

      }

      }

       

       

      四、定義兩個類,描述如下:[必做題]
      1.定義一個人類Person:
      (1)定義一個方法sayHello(),可以向?qū)Ψ桨l(fā)出問候語“hello,mynameisXXX”
      (2)有三個屬性:名字、身高、體重
      2.定義一個PersonCreate類:
      (1)創(chuàng)建兩個對象,分別是zhangsan,33歲,1.73;lishi,44,1.74
      (2)分別調(diào)用對象的sayHello()方法。

      package abc;

      public class Person {

      String name;

      double height;

          int weight;

          int age;

          public void sayhello() {

       

              System.out.println("hello,my name is " + name);

       

              System.out.println("my height is " + height + "米");

       

              System.out.println("my weight is " + weight + "斤");

       

              System.out.println("my age is " + age + "歲");

      }

      public static void main(String[] args) {

      // TODO Auto-generated method stub

      Person a = new Person();

      Person b = new Person();

      a.name ="zhangsan";

      a.age = 21;

      a.height = 1.70;

      a.weight = 130;

      b.name = "lishi";

      b.age = 44;

      b.height = 1.74;

      b.weight = 140;

      a.sayhello();

      b.sayhello();

      }

      }

       

       

      五、定義兩個類,描述如下:[必做題]
      1.定義一個人類Person:
      (1)定義一個方法sayHello(),可以向?qū)Ψ桨l(fā)出問候語“hello,mynameisXXX”
      (2)有三個屬性:名字、身高、體重
      (3)通過構(gòu)造方法,分別給三個屬性賦值
      2.定義一個Constructor類:
      (1)創(chuàng)建兩個對象,分別是zhangsan,33歲,1.73;lishi,44,1.74
      (2)分別調(diào)用對象的sayHello()方法。

       

      package abc;

      public class Constructor {

      String name;

      double height;

      int weight;

      int age;

      public Constructor (String name, double height, int weight,int age) {

      super();

      this.name = name;

      this.height = height;

      this.weight = weight;

      this.age=age;

      }

      public void sayhello() {

      System.out.println("hello,my name is " + name);

      System.out.println("my height is " + height + "米") 

      System.out.println("my weight is " + weight + "千克");

      System.out.println("my age is " + age + "歲");

      }

      public static void main(String[] args) {

      // TODO Auto-generated method stub

      Constructor  a=new Constructor ("zhangsan",1.70,55,73);

      Constructor  b=new Constructor ("lishi",1.76,54,74);

      a.sayhello();

      b.sayhello();

      }

      }

       

       

      六、定義一個汽車類Vehicle,要求如下:[選做題]
      1.屬性包括:汽車品牌brand(String類型)、顏色color(String類型)和速度speed(double類型),并且所有屬性為私有。
      2.至少提供一個有參的構(gòu)造方法(要求品牌和顏色可以初始化為任意值,但速度的初始值必須為0)。
      3.為私有屬性提供訪問器方法。注意:汽車品牌一旦初始化之后不能修改。
      4.定義一個一般方法run(),用打印語句描述汽車奔跑
      的功能
      5.定義測試類VehicleTest,在其main方法中創(chuàng)建一個品牌為“benz”、顏色為“black”的汽車。

      package abc;

       

      public class Vehicle {

      private String brand;

      private String color;

      private double speed;

      public Vehicle(String brand,String color){

      this.brand=brand;

      this.color=color;

      }

      Vehicle(String brand, String color, double speed) {

      super();

      this.brand = brand;

      this.color = color;

      this.speed = speed;

      }

      public void run(){

      System.out.println("這個汽車的品牌為"+this.brand+"這個汽車的顏色為"+this.color+"這個汽車的速度為"+this.speed);

      }

      public static void main(String[] args) {

      Vehicle v=new Vehicle("benz","red");

      v.run();

      Vehicle v1=new Vehicle("benz","black",13);

      v1.run();

      }

      }

      posted on 2023-07-05 22:39  王有勝  閱讀(13)  評論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 欧美牲交a欧美牲交aⅴ一| 亚洲色大成网站WWW永久麻豆 | 乱码精品一区二区三区| 中文精品无码中文字幕无码专区| 人妻少妇精品性色av蜜桃| 俄罗斯美女真人性做爰| 伊人久久综合无码成人网| 日韩精品一二三黄色一级| 欧美日韩人成综合在线播放| av永久免费网站在线观看| 免费人成再在线观看视频| 一个人免费观看WWW在线视频| 狠狠色噜噜狠狠狠狠蜜桃| 成人亚洲av免费在线| 亚欧美闷骚院| gogogo高清在线观看视频中文| 日韩精品视频一二三四区| 亚洲欧美日韩成人综合一区| 久久香蕉国产线熟妇人妻| 伊伊人成亚洲综合人网7777 | 日韩美女亚洲性一区二区| 日韩大片一区二区三区| 国产精品自在线拍国产手青青机版 | 欧美黑吊大战白妞| 娇妻玩4p被三个男人伺候| 国产精品对白刺激久久久| 国产成人精品久久性色av| 亚洲AV成人无码精品电影在线| 少妇被粗大的猛进69视频| 色狠狠色噜噜AV一区| 国产精品自拍实拍在线看| 粉嫩国产av一区二区三区| 国产桃色在线成免费视频| 亚洲精品国偷自产在线| 亚洲av色图一区二区三区| 成人亚洲精品一区二区三区| 蜜臀精品一区二区三区四区 | 国产精品一二三中文字幕| 熟女在线视频一区二区三区| 亚洲人成电影网站 久久影视| 色又黄又爽18禁免费视频|