定义汽车类

来源:百度知道 编辑:UC知道 时间:2024/06/22 02:39:42
,此类任意添加两个属性,也就是说定义两个成员变量,同时添加两个方法,其一:加速方法addSpeed(),其二:刹车方法Stop().
要求:1、在CAR类中加main()方法,测试程序的运行结果。

用c#写的 不知道可以么?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace car
{
public class car
{
private string name;
private int id;
private string output = " ";
public car() { }
public car(string name, int id)
{
this.name = name;
this.id = id;
}

public string Name
{
get { return name; }
set { name = value; }
}
public int ID
{
get { return id; }
set { id = value; }
}
public string Addspeed()
{

return output = " 汽车加速!";
}
public string Stopspeed()
{
return output =" 汽车刹车! ";