c#编写一个立方体box类,调用构造函数的方法

[复制链接]
查看11 | 回复2 | 2013-1-24 11:55:44 | 显示全部楼层 |阅读模式
class box{ private int len,wid.high; public box() { len=0; wid=0; high=0; }public box(int len,int wid,int high){this.len=len;this.wid=wid;this.high=high;} public int a()周长{ return 4*(len+wid+high);}public int b()体积{return len*wid*high;} public int len(){ return this.len;}其他输出wid、high的类似 就不写了 public void setlen(int len){ this.len=len;}}其他修改wid、high的类似 就不写了}赞同0|评论
回复

使用道具 举报

千问 | 2013-1-24 11:55:44 | 显示全部楼层
public class box{private int len;private int wid;private int high;public box(){len =0;wid=0;high=0;}public box(int len,int wid,int high){this.len =len;this.wid=wid;this.high=high;} 周长public int zhouchang(int len,int wid,int high){周长计算方法return 计算结果(int 类型)}体积 public int zhouchang(int len,int wid,int high){体积计算方法return 计算结果(int 类型)} }赞同0|评论
回复

使用道具 举报

千问 | 2013-1-24 11:55:44 | 显示全部楼层
private class Box{
private float len=0;
private float wid=0;
private float high=0;
public Box(){}
public Box(float len,float wid,float high){this.len=len;this.wid=wid;this.high=high;}public float QueryPerimeter(float len, float wid, float high){float result=0;result =4*(len +wid+high);return result;}public float QueryArea(float len,floatwid, floathigh){float result =0;result =len* wid*high;return result;}public void Write(){Console.Write(string.Format(长为{0},this.len));Console.Write(string.Format(宽为{0},this.wid));Console.Write(string.Format(高度{0},this.high));}public void Modify(float len,float wid,float high){this.len=len;this.wid=wid;this.high=high;}}赞同0|评论
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行