class square { private point rVertex; //左顶点 private int side; //边长
//构造一个正方形 public square(point rVertex, int side) { this.rVertex = rVertex; this.side = side; } //返回正方形的面积 public int getAcreage() { return side * side; } }
/* * Created on 2005-1-6 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package org.javapitfalls.item1; /** * @author Administrator * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ class Point{ private int pX; private int pY; public Point(int px,int py){ this.pX = px; this.pY = py; } public int getX(){ return pX; } public int getY(){ return pY; } public void setX(int x){ this.pX=x; } public void setY(int y){ this.pY=y; } } public class TestSquare { private int borderLen; Point initPoint; public TestSquare(int borderLen,Point initPoint){ this.borderLen=borderLen; this.initPoint=initPoint; } public int getArea(){ return borderLen*borderLen; } public void setBorderLen(int borderLen){ this.borderLen=borderLen; } public int getBorderLen(){ return this.borderLen; } public void setInitPoint(Point init){ this.initPoint=init; } public Point getInitPoint(){ return this.initPoint; } public static void main(String[] args) { } }
{
private point rVertex; //左顶点
private int side; //边长
//构造一个正方形
public square(point rVertex, int side) {
this.rVertex = rVertex;
this.side = side;
} //返回正方形的面积
public int getAcreage() {
return side * side;
}
}
* Created on 2005-1-6
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.javapitfalls.item1;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
class Point{
private int pX;
private int pY;
public Point(int px,int py){
this.pX = px;
this.pY = py;
}
public int getX(){
return pX;
}
public int getY(){
return pY;
}
public void setX(int x){
this.pX=x;
}
public void setY(int y){
this.pY=y;
}
}
public class TestSquare {
private int borderLen;
Point initPoint;
public TestSquare(int borderLen,Point initPoint){
this.borderLen=borderLen;
this.initPoint=initPoint;
}
public int getArea(){
return borderLen*borderLen;
}
public void setBorderLen(int borderLen){
this.borderLen=borderLen;
}
public int getBorderLen(){
return this.borderLen;
}
public void setInitPoint(Point init){
this.initPoint=init;
}
public Point getInitPoint(){
return this.initPoint;
}
public static void main(String[] args) {
}
}