第九周作业。

1.

package jv;

public class zuoye {
    int x;
    int y;

    Point() {

    }

    Point(int x0, int y0) {
        this.x = x0;
        this.y = y0;
    }

    public void movePoint(int dx, int dy) {
        this.x += x;
        this.y += y;
        System.out.println("坐标" + this.x + "," + this.y);
    }
}

2.

package jv;
 
public class zuoye {
     private int length;
     private int width;
 
     Rectangle_func( int length, int width) {
         this .length = length;
         this .width = width;
     }
 
     public void showAll() {
         System.out.println( "矩形长为:" + length + "\t" + "矩形的宽为:" + width);
         System.out.println( "矩形的面积为:" + getArea() + "\t" + "矩形的周长为:" + getPer());
     }
 
     public int getPer() {
         return 2 * (length + width);
     }
 
     public int getArea() {
         return length * width;
     }
 
}
package jv ;
 
public class zuoye {
 
     public static void main(String[] args) {
         // TODO Auto-generated method stub
         Rectangle_func r = new Rectangle_func( 4 , 6 );
         r.showAll();
     }
 
}
 
3.
package jv;

public zuoye {
    char color;
    int cpu;
    Macbook() {

    }
    Macbook(char color, int cpu) {
        this.color = color;
        this.cpu = cpu;
    }
    void a() {
        System.out.println("颜色:" + color + "  型号:" + cpu);
    }
}
4.
package jv;

public class zuoye{
    String name;
    double height;
    int weight;
    int age;

    public void sayHello() {
        System.out.println("hello my name is   " + name + "  height是" + height + "  weight是" + weight);
    }
    public void Person1(String name,int age) {
        System.out.println("姓名是"+name+"年龄是"+age);
    }
}
package jv;

public class zuoye {

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        Person2 P = new Person2();
        Person2 p1 = new Person2();
        P.name = "wangwu";
        P.height = 1.73;
        P.weight = 66;
        P.sayHello();
        P.Person1("zhansan", 23);
        p1.name = "lishi";
        p1.height = 1.74;
        p1.age = 44;
        p1.weight=55;
        p1.sayHello();
    }

}
   

猜你喜欢

转载自www.cnblogs.com/Mfb-/p/12808069.html