C++ 汽车类的问题![声明,本人表述能力差,各位多担待!]
											
用c++的知识,写一个汽车类,要求三个方法 run() stop() speedup().四个属性。要在启动汽车后才可以停止和加速。并且速度的起始值是50.每加一次,速度加5,并且显示此时汽车的状态。先按停止,提示汽车没启动。我自己写了个,杯具呀!我写的暂时没有写颜色重量等四个属性,纠结在三个成员函数对于功能的实现上。
求指导!讨论!BS,我深刻意识到我大学的时光白白浪费了。。。。
程序代码:#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <string>
using namespace std;
class CCar
{
    public:
      void carRun()
      {
        //string c;
        //cout<<"请输入r/R后回车启动汽车:";
        //cin>>c;
        cout<<"汽车启动成功.初始速度:50KM/S。"<<endl<<endl;
       };
      
     void carStop()
      {
        //string s;
        cout<<"汽车已停止前进."<<endl;
      };
      int carspeedUp()
      {
       //
      //    {
          //string s;
          //cin>>s;
           //speed =50;
        
            int i;
           // i = 50;
                i = i+5;
            cout<<"现在速度是:"<<i<<"KM/S."<<endl;    
            return i;
         // }
      }
    //private:
    //int speed;
};
int main()
{   string c;
  int speed;
  int i;
  i=50;
        // cout<<"请输入r/R启动汽车:";
        //cin>>c;
    cout<<"按r/R后回车启动汽车,启动后按s/S停止前进,按a/A加速:"<<endl; 
    CCar car1;
  
  while (c!="e"||c!="E")
    {  
         cout<<endl;
         cin>>c;
          cout<<endl;
         cout<<"请继续进行操作:";
         cout<<endl
         <<"启动后按s/S停止前进,按a/A加速:"
         <<endl
         <<"按e/E键退出。"<<endl<<endl;
       
         if (c=="R"||c=="r" )
           {   
           car1.carRun();
           //cout<<"汽车启动成功.现在速度是50km/s。"<<endl<<endl;
         }
        else if (c=="s"||c=="S")
            {cout<<"先按r/R启动汽车。" ;
             cout<<"汽车没有正常启动!";
            }
     //cout<<"下一步操作:" ;
     //cin>>c;
    
         if (c=="s"||c=="S")
           {
               car1.carStop();
           }
              
                   // {
           //  cout<<"汽车已停止前进."<<endl<<endl;
            //}
          //else
          //    {
              //   cout<<"请先启动汽车。" <<endl;
            // }
           
     if (c=="a"||c=="A")
        {
         car1.carspeedUp();
        }
    
     if (c=="e"||c=="E")
    
    
     break;
//cout<<"下一步操作:" ;
  //    cin>>c;
    
    
    }}
    
    
  /* for (speed=50;speed<=300;speed++)
        
{
    cin>>c;
    if (c=="s"||c=="S")
          {
          cout<<"汽车已停止前进."<<endl<<endl;
          }
       else {
           cout<<"请先启动汽车。" ;
       }
       if  (c=="a"||c=="A")
         {car1.carspeedUp(i);
         cout<<speed;}
         else {cout<<"请先启动汽车。"; }
       }
        
    }*/
   
   
//{for ((c=="R"||c=="r")&&(su=="s"||su="S")    )
//{
//cout<<"汽车已停止前进."<<endl<<endl;   
//}}
//}!多谢了!分不多!
[ 本帖最后由 色盲怎注册 于 2011-3-23 14:19 编辑 ]

											