package Zh123;
public class Point {
int x;
int y;
public Point(int x0, int y0) {
x = x0;
y = y0;
}
public Point() {
}
public String movePoint(int dx, int dy) {
x = x + dx;
y = y + dy;
return ("(x,y)" + "" + "("+x +","+ y+")");
}
public static void main(String[] args) {
Point p1 = new Point(2, 5);
Point p2 = new Point(3, 6);
System.out.println("p2是" + p2.movePoint(1, 1));
System.out.println("p1是" + p1.movePoint(5, 2));
}
}
package Zh123;
public class Rectangle {
int length;
int width;
public int getArea(int length, int width) {
int Area;
Area = length * width;
return Area;
}
public int getPer(int length, int width) {
int Per;
Per = (length + width) * 2;
return Per;
}
public void showAll() {
System.out.println("长度是" + length + " " + " 宽度是" + width + " " + "周长是"
+ (length + width) * 2 + " " + "面积是" + length * width);
}
public Rectangle(int length, int width) {
this.length = length;
this.width = width;
}
public static void main(String[] args) {
Rectangle a = new Rectangle(5, 7);
a.showAll();
}
}
package Zh123;
public class Note {
char color;
int cpu;
public Note(char color,int cpu){
this.color =color;
this.cpu=cpu;
}
public void show(){
System.out.println("笔记本颜色是"+color+" "+"型号是"+cpu);
}
}
package Zh123;
public class NoteTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Note a1=new Note ('黑',2);
Note a2=new Note('银',1);
a1.show();
a2.show();
}
}