码迷,mamicode.com
首页 > 其他好文 > 详细

第十二次作業

时间:2021-05-25 18:20:04      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:todo   void   system   png   eth   auto   @param   技术   oid   


public class Point {
int x;
int y;

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

public Point() {
super();
}

public void movePoint(int dx, int dy) {
this.x += dx;
this.y += dy;

}

public static void main(String[] args) {
Point p1 = new Point(3, 7);
p1.movePoint(5, 8);
System.out.println("p1的X坐标为:" + p1.x + "p1的Y坐标为:"+p1.y);
Point p2 = new Point(4, 9);
p2.movePoint(3, 8);
System.out.println("p2的X坐标为:" + p2.x + "p2的Y坐标为:"+p2.y);

}

}

技术图片

 

 


public class Rectangle {
int length;
int width;

public Rectangle(int length, int width) {
this.length = length;
this.width = width;
}

public int getArea() {
return length * width;
}

public int getPer() {
return (length + width) * 2;
}

public void showAll() {
System.out.println("长为:" + length);
System.out.println("宽为:" + width);
System.out.println("面积为:" + getArea());
System.out.println("周长为:" + getPer());
}

public static void main(String[] args) {
Rectangle s1 = new Rectangle(9, 2);
s1.showAll();
}

}

技术图片

 

 


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);
}

}

 

 


public class TExtbjb {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
bjb b1 = new bjb(‘黑‘, 9);
bjb b2 = new bjb(‘白‘, 10);
b1.show();
b2.show();
}

}

 技术图片

 

第十二次作業

标签:todo   void   system   png   eth   auto   @param   技术   oid   

原文地址:https://www.cnblogs.com/gyxnb/p/14808247.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!