标签: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