博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

3桌子作业讲解.avi

Posted on 2010-10-06 11:16  EVON168  阅读(151)  评论(0编辑  收藏  举报

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DeskTask
{
    
public class Desk
    {
        
private int _length;

        
public int Length
        {
            
get { return _length; }
            
set { _length = value; }
        }
        
private int _width;

        
public int Width
        {
            
get { return _width; }
            
set { _width = value; }
        }
        
private int _height;

        
public int Height
        {
            
get { return _height; }
            
set { _height = value; }
        }

        
public int volume//体积
        {
            
get
            {
                
return _length * _width * _height;
            }
        }

        
public int area//面积
        {
            
get
            {
                
return _length * _width;
            }
        }

        
public Desk():this(1,1,1)
        {

        }

        
public Desk(int length, int width):this(length,width,0)
        {
            
        }

        
public Desk(int length, int width, int height)
        {
            
this._length = length;
            
this._width = width;
            
this._height = height;
        }

        
public bool Compare(Desk desk)
        {
            
return this.volume > desk.volume;
        }
    }


    
class Program
    {
        
static void Main(string[] args)
        {
            Desk d1 
= new Desk(123);
            Desk d2 
= new Desk(345);

            Console.WriteLine(d1.Compare(d2));
        }
    }
}