啊,苍天,大地啊,我确实连体积的英文名都不会写。 赶紧去查了查: volume: [ 'vɔlju:m; (US) -jəm ] n. 体积,容量,音量 n. 卷,册 例句与用法: 1. The television is too loud; turn the volume down. 电视声音太响了,把音量调低点儿。
2. The volume of this container is 20 cubic meters. 这个集装箱的体积是20立方米。
3. Is that volume still in print? 那册书还能买到吗?
英英解释: 名词volume:1. the amount of 3-dimensional space occupied by an object2. the property of something that is great in magnitude 同义词:bulk, mass3. physical objects consisting of a number of pages bound together 同义词:book4. a publication that is one of a set of several similar publications5. a relative amount6. the magnitude of sound (usually in a specified direction) 同义词:loudness, intensity
class TableClass
{
private float length;
private float width;
private float height;
public float Length
{
get{return this.length;}
set{this.length=value;}
}
public float Width
{
get{return this.width;}
set{this.width=value;}
}
public float Height
{
get{return this.height;}
set{this.height=value;}
} public TableClass(float length,float width,float height)
{
if(length>0 && width>0 && height>0)
{
this.length=length;
this.width=width;
this.height=height;
}
} public float GetVoulumn()
{
return length*width*height;
}
}
class Table
{
private float height;
private float width;
private float size; public Table()
{
height = width = size = 0;
} public Table(float size, float width, float height)
{
this.height = height;
this.width = width;
this.size = size;
}
public float Height
{
get { return height; }
set
{
if (height > 0)
{
height = value;
}
}
}
public float Width
{
get { return width; }
set
{
if (width > 0)
{
width = value;
}
}
} public float GetArea(Table table)
{
return table.Height * table.width * table.size;
}
public float Size
{
get { return size; }
set
{
if (size > 0)
{
size = value;
}
}
}
}
class TableClass
{
private float length=0;
private float width=0;
private float height=0;
public float Length
{
get{return this.length;}
set{
if(value>0)
this.length=value;}
}
public float Width
{
get{return this.width;}
set{if(value>0)this.width=value;}
}
public float Height
{
get{return this.height;}
set{if(value>0)this.height=value;}
} public TableClass(float length,float width,float height)
{
if(length>0 && width>0 && height>0)
{
this.length=length;
this.width=width;
this.height=height;
}
} public float GetVoulumn()
{
return length*width;
}
}
//one
class Table
{
private float length;
private float width;
private float height; public float GetTiJi(float l, float w, float h)
{
return l * w * h;
}
}//two
class Table
{
public float GetTiJi(float l, float w, float h)
{
return l * w * h;
}
}//three
class Table
{
public float length;
public float width;
public float height; public float GetTiJi(float l, float w, float h)
{
return this.lenght * this.width * this.height;
}
}//four
class Table
{
private float length;
private float width;
private float height;
public float Length
{
get { return this.length; }
set { this.length = value; }
}
public float Width
{
get { return this.width; }
set { this.width = value; }
}
public float Height
{
get { return this.height; }
set { this.height = value; }
} public float GetTiJi(float l, float w, float h)
{
return this.lenght * this.width * this.height;
}}
面试题:用C#编写一个桌子类,类中有三个属性:长、宽、高,一个方法,方法的功能为获得桌子的体积。
*/class 桌子
{
decimal l, w, h;
public decimal 长 { get { return l; } set { l = value; } }
public decimal 宽 { get { return w; } set { w = value; } }
public decimal 高 { get { return h; } set { h = value; } }
public decimal 体积() { return 长 * 宽 * 高; }
}
我看过大多数楼上写的代码
//我可以大声的说。你们写的都很不好---------------
虽然不好听 , 但是是实话
说实在的 如果让我给你们写的代码打分 最多3分(5分满)
----------------
你们代码不好的原因很简单
那就是扩展性不好,灵活性不好
----------------
C# 是一门 OOP语言
你没没有充分的体现OOP特性
直接封装字段 只是面向对象的一部分
其他的呢?
---------------------------------------------------------------
1.做桌子抽象类 TABLE
2.做接口 interface IComputedarea
{
double doCompute(TABLE t);
}
3.做个各种如(圆,方,三角。)计算的方法
4.用不同的桌子的子类去继承TABLE后实现接口就行了也不拍在扩展
严重同意:
我觉得开发人员都有这类毛病,面试和被面试是不同的心态按模式来设计——往往很多系统根本达不到需要模式设计的需求,硬要往这方面靠拢
过度的追求耦合度的高低——鄙视,呵呵~~
││博客空间:http://blog.csdn.net/lovingkiss
││资源下载:http://download.csdn.net/user/lovingkiss
││Email:loving-kiss@163.com [MSN也是这个]
││联系方式:Q66840199 项目、聊天、咨询、探讨、统统收费,呵呵......
╚---------------------------------------------------------------------------------------------------------ō*︻$▅▆▇◤
你题目出的不好,你说的很清楚是"一个类",一般人都不会想到建接口或者基类吧。
你把你测试用main函数给出,让他们自由发挥会比较好
static void Main(string[] args)
{
ClsTabel tableA = new ClsTable(10,20,30);
Console.WriteLine("Volume is "+tableA.GetVolume());ClsTabel tableB = new ClsTable(10.0,20.0,30.0);
Console.WriteLine("Volume is "+tableB.GetVolume());
}
不就三个变量,把三个变量弄成类的属性,用以输入数据,再来一个计算面积的方法么,计算面积要能输出,那就是要在MIAN方法里面实现咯。汗!
我想只不过是没有想到lz一样的想法吧?lz可能是要接口、继承、多态什么的。
那你应该直接说明。人家面试的怎么可能想到和你一样?
lz不会问问题啊!学学李开复,看人家是怎么提问的?按lz本身的问题来看,ls的都可以,不过lz后面的意思可能是说需要用个变化的思维来看。那么请把变化的场景给出来,实际是不同的场景有不同设计方式。你可以使用工厂,也可以用装饰模型--------,这种问题没有所谓的标准答案!
传说用Decimal 更精确
尤其在有关金钱计算时用
GetTiJi!哈哈,太搞笑了!
我是计算机专业的 同学什么水平我最清楚 平时一个能运行的程序都做不出来
毕业设计 课程设计 实验就会找人帮忙 网上下载 根本别指望所有的计算机专业的学生都会程序当然高手是有的 少罢了 一个班的实验就那么2 3个版本
作为招聘的你们 怎么能考出学生的水平来应该有你们的方法 不行的直接刷掉就是了 何必来这发帖找骂?
我相信经常来这论坛的逛 都是很鄙视你那个题目的 太EASY+白痴了一点点
赶紧去查了查:
volume: [ 'vɔlju:m; (US) -jəm ] n. 体积,容量,音量
n. 卷,册
例句与用法:
1. The television is too loud; turn the volume down.
电视声音太响了,把音量调低点儿。
2. The volume of this container is 20 cubic meters.
这个集装箱的体积是20立方米。
3. Is that volume still in print?
那册书还能买到吗?
英英解释:
名词volume:1. the amount of 3-dimensional space occupied by an object2. the property of something that is great in magnitude
同义词:bulk, mass3. physical objects consisting of a number of pages bound together
同义词:book4. a publication that is one of a set of several similar publications5. a relative amount6. the magnitude of sound (usually in a specified direction)
同义词:loudness, intensity
Class Desk
{
private decimal m_desk_length;
public decimal desk_length
{
get {return m_desk_length;}
set {m_desk_length = value;}
}
private decimal m_desk_width;
public decimal desk_width
{
get {return m_desk_width;}
set {m_desk_width = value;}
} private decimal m_desk_height;
public decimal desk_height
{
get {return m_desk_height;}
set {m_desk_height = value;}
} public decimal GetDeskVolume(decimal l,decimal w,decimal h)
{
if(l>0&&w>0&&h>0)
return l*w*h;
else
teturn -1;
}
}
for(int i=1;i<=2;)
{
Response.Write("UP");
}