注册 登录
编程论坛 ASP.NET技术论坛

[求助]一道ASP.NET的问题

pengson 发布于 2007-07-03 15:11, 1030 次点击

对于一个长方形, 它有长和宽, 构造一个类, 类名叫Rect. 类中要描述它的周长和面积求法*

谢谢不知道怎么写>>

13 回复
#2
随风逐流2007-07-03 15:18
class Rect
{
private int a;
private int b;
rect(int c,int d)
{
a=c;
b=d;
}
public int mian()
{
return a*b;
}
}
#3
pengson2007-07-03 15:40
谢谢!
上面好似面积!
那周长2×(长+宽)怎么加进去呢???
#4
随风逐流2007-07-03 15:43

加个类似的方法就行了
public int mian()
{
return 2*(a+b);
}

#5
pengson2007-07-03 15:46
哇,学习asp。net学到我吐血啊。。。。。
#6
随风逐流2007-07-03 16:33

你应该先去学基础的嘛

#7
垃圾的沉默2007-07-03 19:12

建议从C++学起。。C++这样的课题太多了

#8
pengson2007-07-04 07:54
好的,我会听从你地既意见,放假我要补一补先,多谢晒各位!
#9
pengson2007-07-05 11:37

运行了之后没MAIN入口,请问要怎么修改///???

#10
冰彩虹2007-07-05 12:23
也太门外汗了吧

class Rect
{
private int a;
private int b;
//构造函数
public rect(int c,int d)
{
a=c;
b=d;
}

public int Area()
{
return a*b;
}
public int Girth()
{
return 2*(a+b);
}
}

public class Temp
{
static void Main()
{
Rect rect=new Rect(3,4);
Console.Write("面积:" + rect.Area());
Console.Write("周长:" + rect.Girth());
}
}
#11
lmedia2007-07-12 13:15

#12
jyoseyi2007-07-13 17:09
基础!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#13
chiansy2007-08-07 12:31

暈倒..........

#14
taoxinhui2007-08-07 13:52

还好,能看的懂.顶下

1