紀錄我的成長空間
2010年3月21日 星期日
class P{
int x,y;
public P(int x,int y){
this.x = x;
this.y =y;
}
}
class Rect{
P upperleft;
P lowleft;
public Rect(P upperleft,P lowleft){
this.lowleft = lowleft;
this.upperleft = upperleft;
}
public Rect(){
this(new P(0,0),new P(5,-5));
}
public Rect(int x1,int y1,int x2,int y2){
this(new P(x1,y1),new P(x2,y2));
}
public int area(){
return (lowleft.x-upperleft.x)*(upperleft.y-lowleft.y);
}
}
public class OverloadConstructor {
public static void main(String args[]){
Rect a = new Rect(0,0,5,-5);
System.out.print(a.area());
}
}
張貼者:haowei @
上午9:50
0 個意見
class P{
int x,y;
public P(int x,int y){
this.x = x;
this.y =y;
}
}
class Rect{
P upperleft;
P lowleft;
public Rect(P upperleft,P lowleft){
this.lowleft = lowleft;
this.upperleft = upperleft;
}
public Rect(){
this(new P(0,0),new P(5,-5));
}
public Rect(int x1,int y1,int x2,int y2){
this(new P(x1,y1),new P(x2,y2));
}
public int area(){
return (lowleft.x-upperleft.x)*(upperleft.y-lowleft.y);
}
}
public class OverloadConstructor {
public static void main(String args[]){
Rect a = new Rect(0,0,5,-5);
System.out.print(a.area());
}
}
張貼者:haowei @
上午9:33
關於我自己
名稱:
haowei
檢視我的完整簡介
連結
Google News
Edit-Me
Edit-Me
先前的文章
class P{ int x,y; public P(int x,int y){ thi...
class P{ int x,y; public P(int x,int y){ this....
封存
3月 2010
訂閱
文章 [
Atom
]