第十二周作业

package Class;

 

public class Class1 {

 

public static void main(String[] args) {

// TODO Auto-generated method stub

     Point p1 = new Point(1,2);

     p1.movePoint(1,2);

     Point p2 = new Point(4,6);

     p2.movePoint(4,6);

}

}

class Point{

int x;int y;

public Point() {

}

public Point(int x0, int y0) {

super();

this.x = x;

this.y = y;

}

void movePoint(int x0, int y0) {

x = x0+1;

y = y0+5;

 System.out.println("p1的坐标是:"+x+","+y);

System.out.println("p2的坐标是:"+x+","+y);

}

}

package learn;

public class Rectangle {
    private int length;
    private int width;
    Rectangle(int length,int width){
        this.length=length;
        this.width=width;
    }
    public void showAll(){
        System.out.println("矩形长为:"+length+"矩形的宽为:"+width+"矩形的面积为:"+getArea()+"矩形的周长为:"+getPer());
    }
    public int getPer(){
        return 2*(length+width);
    }
    public int getArea(){
        return length*width;
    }

}




Rectangle r=new Rectangle(5,8);
        r.showAll();

    }

}

package bbb;

public class Bjb {
    char color;
    int cpu;

    public Bjb() {
        super();
    }

    public Bjb(char color, int cpu) {
        super();
        this.color = color;
        this.cpu = cpu;
    }

    public void show() {
        System.out.println("笔记本颜色是:" + color + "cpu型号是:" + cpu);
    }

}
package bbb;

public class Bjb1 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
            Bjb b1 = new Bjb('粉',2);
            Bjb b2 = new Bjb('蓝',3);
            b1.show();
            b2.show();
        }

    }

posted @ 2021-05-23 17:29  五谷鸡爪🥳  阅读(26)  评论(0编辑  收藏  举报