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

using System; namespace dirtysalt{ public class Car//class of car,has attribute of 'weight' and 'speed' { private int weight; private int speed; public Car(int Weight,int Speed){ weight=Weight; speed=Speed; } public void setweight(int Weight){ weight=Weight; } public void setspeed(int Speed){ speed=Speed; } public int getspeed(){ return speed; } public int getweight(){ return weight; } };

public class Sportcar:Car//inherit class of Car,has attributes of 'weight','speed','color' { private string color; public Sportcar(int Weight,int Speed,string Color):base(Weight,Speed) { setweight(Weight); setspeed(Speed); color=Color; } public void setcolor(string Color){ color=Color; } public string getcolor(){ return color; } public static void Main() { Car car=new Car(100,100); Sportcar sportcar=new Sportcar(100,200,"blcak");//here has a problem Console.WriteLine("car's weight is "+car.getweight()); Console.WriteLine("car's speed is "+car.getspeed()); Console.WriteLine("sportcar's weight is "+sportcar.getweight()); Console.WriteLine("sportcar's speed is "+sportcar.getspeed()); Console.WriteLine("sportcar's speed is "+sportcar.getcolor()); } } } 希望对大家有帮助!!!!!!

ps:没有代码说明

[此贴子已经被幻风幻云于2005-4-4 19:31:16编辑过]

搜索更多相关主题的帖子: 代码 推荐 不独 
2005-04-04 18:38
快速回复:[推荐]好代码不独享
数据加载中...
 
   



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

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