Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2341443
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:07:13


#include
#include
#include
#include
#include
using namespace std;
#define MAX 5                          //可显示5只股票的交易状况
class Stock                             //股票类
{
  //class Customer;
  friend class Customer;
  private:
          char StockName[20];            //股票名称
          char StockCode[6];              //股票代码
          char choice;
          int NumOfStock;                //索引
          long int StockVolume;            //股票的总数
          long int VolumeAvailable;         //可交易的数量
  public:
    //class Customer;
       
        Stock();                        //构造
        void Interface();                  //股市界面
        void StockExchangeMarket();         //输入信息
void SwitchChoice();                //选择命令执行
void InputForNewStock();            //输入新股票信息
//friend int *strcmp (string ,string);
};  
 Stock s[MAX],temp;                         //5支股票对象
 class Customer                              //用户类
 {
private:
       char CustomerName[30];            //用户名
       char Password[10];                  //密码
       char ShareHoldingName[30];          //拥有的股票名称
       char ShareHoldingCode[5];            //拥有的股票代码
       char AnyChar;                      //存放任意字符变量
       long int ShareHoldingValue;            //拥有的股票数量
public:
       Customer(const char  a[30],const char b[30],const char c[5]);
       void Login(char* ,Customer) const;         //用户登陆
       void Register(Customer cust) const;             //用户开户
       void StockPortfolio (Customer cust) const;        //用户交易操作
};
Customer::Customer(const char  a[30]=" ",const char b[30]=" ",const char c[5]=" ")                          //默认构造,清零
{  strcpy (CustomerName,  a);
   strcpy (ShareHoldingName, b );
    strcpy (ShareHoldingCode, c );
   ShareHoldingValue=0;
}
//void Customer::Login(char * password, Customer cust) const
//{   ifstream read_customer("customer.dat"
void Customer::Login(char*password,Customer cust) const
{  ifstream read_customer("customer.dat");                    //读入数据文件
while(!read_customer.eof( ))
    {
read_customer.read((char*)(&cust),sizeof(cust));
    if(read_customer.fail( ))
cout<<"NO record at all!";
        break;
}
if(strcmp(cust.Password,Password)==0)  {                 //验证密码
  StockPortfolio(cust);                               //密码正确,进行交易操作
}
  read_customer.close( );
}
void Customer::Register(Customer  cust)   const                     //用户开户
{    system("cls");                                        //执行系统命令:清屏
     cin.get( );
     cout <<"\t\t欢迎交易市场开户!"<     cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~"<     cout <<"请输入您的姓名.";
     cin.getline(cust.CustomerName,30,'\n');
     cout <<"请输入您的密码(少于8个字符):";
     cin>>cust.Password;///////////////////////////////////
     cin.get( );
     system ("cls");
     cout <     cout <<"您的帐户已被建立,可以开始交易```````"<     cout <<"按任意键开始``````````"<     //cin.getch( );
     cin>>AnyChar;//getch( )
}
void Customer::StockPortfolio(Customer  cust) const              //用户股票操作
{Stock share[MAX],temp;
 Customer ss[MAX];
int i;
char ch,AnyChar,ShareCode[6];
long int volume;
goto start;
   system("cls");
cout <cout <<"\t\t\t 欢迎返回!"    <cout <<"\t\t   股票交易系统  "<cout <<"\t\t*****************************"<cout <<"\t\t 用户 "<cout <<"\t\t  买股票 ********************* [b]"<cout <<"\t\t  卖股票  *********************[s]"<cout <<"\t\t  查看用户帐号******************* [v]"<cout <<"\t\t  登出*********************  [q]"<cout <cin>>ch;
if((ch!='v')&& (ch!='b') && (ch!='s') && (ch!='q')) {
goto start;

}else{
switch(ch)
case'b'://买股票
{ system("cls");
cout<<"\n\n\t\t股票交易系统"<cout<<"名称\t交易代码\t在册册数\t可交易股数"<ifstream dataFile("Stock_File.dat");                       //  输入股票市场情况          
dataFile.read(

--------------------next---------------------

阅读(1095) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~