第十次作业

public class l {
        int x;
        int y;

        l() {

        }

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

        public void movePoint(int dx, int dy) {
            System.out.println("前坐标" + this.x + "," + this.y);
            this.x += x;
            this.y += y;
            System.out.println("后坐标" + this.x + "," + this.y);
        }
        public static void main(String[] args) {       
           l p1 = new l(1,1);
           l p2 = new l(2,2);
           p1.movePoint(3,3);
           p2.movePoint(4,4);   
            }
}

 

 

 

 

public class l {
    int length;
    int width;
     
         public l(int length, int width) {
             super();
             this.length = length;
             this.width = width;
     }
     
        public int getArea(int length, int width) {
         return this.length * this.width;
         }
    
        public int getPer(int length, int width) {
            return 2 * (this.length + this.width);
        }
     
        public void showAll() {
             System.out.println("长为" + length + ",宽为" + width);
            System.out.println("面积为" + getArea(this.length, this.width));
           System.out.println("周长为" + getPer(this.length,this. width));
     
         }
     
         public static void main(String[] args) {
            l r = new l(5,6);
             r.showAll();

     }
}

 

 

 

 

public class l {
    char color;
    int cpu;
    
    void information(){
        System.out.println("笔记本颜色为:"+color+"\n笔记本的型号为:"+cpu);
    }
    
    l(){}
    l( char color, int cpu ){
        this.color = color;
        this.cpu=cpu;
        information();
    }
    public static void main(String[] args) {
        l information=new l('c',10001);
       
        }
}

 

posted @ 2021-05-25 10:47  假̶装̶乐̶观̶♡̶  阅读(21)  评论(0编辑  收藏  举报