2010年4月8日 星期四

建構子程式

class d9539186

{

public static void main(String[] args)
{
int w,u;
int a,b;
a=6;
b=8;

Triangel Alan1 = new Triangel();
Ractabgle Alan2 = new Ractabgle();

u=Alan1.add(a,b);
w=Alan2.add(a,b);
System.out.println(u);
System.out.println(w);
}

}

class Triangel
{
static int add(int a,int b)
{
int x,y,z;
x=a;
y=b ;
z=(x*y)/2;
return z ;
}
}
class Ractabgle
{
static int add(int a,int b)
{
int x,y,z;
x=a;
y=b ;
z=x*y;
return z ;
}
}


沒有留言:

張貼留言