| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1494 人关注过本帖
标题:[推荐]好代码不独享
只看楼主 加入收藏
nyzfl
Rank: 1
等 级:新手上路
帖 子:278
专家分:0
注 册:2005-3-21
收藏
得分:0 
ok

My-Blog地址:http://fenglin.
2005-04-14 12:59
leeteng
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2005-1-7
收藏
得分:0 
using System;
namespace dirtysalt{
public   class Car//class of car,has attribute of 'weight' and 'speed'
{
  proected int weight;
    proected int speed;
  proected string color
  public Car(int Weight,int Speed,string Color){
   weight=Weight;
   speed=Speed;
color = Color;
  }
  public  int  Weight{
get{return weight;}
set{weight = value;}
}
 public  int  Speed{
get{return speed;}
set{speed = value;}
}
public string Color{
get{return color;}
set{color = value;}
}
}
public class Sportcar:Car//inherit class of Car,has  attributes of 'weight','speed','color'
{
    public  Sportcar(int Weight,int Speed,string Color):base(Weight,Speed,Color)
{   }
}
     public static void Main()
   {
   
    Sportcar sportcar=new Sportcar(100,200,"blcak");//here has a problem
        
    Console.WriteLine("sportcar's weight is "+sportcar.Weight);
    Console.WriteLine("sportcar's speed is "+sportcar.Speed);
    Console.WriteLine("sportcar's speed is "+sportcar.Color);
   }
}
}
注:不存在没有颜色的车吧,所以把颜色放入父类不是很好吗?而且,重量,颜色可以看作是车的属性啊。 你觉得呢。
2005-04-14 15:23
BarbieChang
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-12-16
收藏
得分:0 

顶哦~!~!

有注释就好看多了,要不像我这样的菜鸟都看的晕晕的~·


2005-12-16 08:55
唐伯猫
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:5323
专家分:58
注 册:2005-8-9
收藏
得分:0 
是好东西.

<iframe name="alimamaifrm" frameborder="0" marginheight="0" marginwidth="0" border="0" scrolling="no" width="300" height="170" src="/go/app/tbk_app/chongzhi_300_170.php?pid=mm_28854300_2441872_11377541&page=chongzhi_300_170.php&size_w=300&size_h=170&stru_phone=1&stru_game=1&stru_travel=1" ></iframe>
2005-12-17 09:01
dien5019
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-12-24
收藏
得分:0 


加点注释就好了!

2005-12-24 12:43
marer
Rank: 2
等 级:新手上路
威 望:3
帖 子:928
专家分:0
注 册:2005-7-18
收藏
得分:0 
这段代码有什么特别之处吗?没有看出来啊?很基础啊

public class 人生历程 extends Thread{public void run(){while(true){努力,努力,再努力!!;Thread.sleep(0);}}}
2005-12-26 11:59
快速回复:[推荐]好代码不独享
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013567 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved