C++实现公司设备管理系统

1.

1.1 设计内容:

编写一个简单的实验室设备管理程序,帮助管理实验室设备信息。要求具有设备信息管理的功能。其中包括设备信息的录入、删除、查询和修改等功能。还应包括对实验室信息管理的功能。其中包括对实验室信息的录入、删除、修改和查询等功能。

1.2 任务和要求

运用面向对象的程序设计方法,要求选择动态数组类模板或链表类模板,任务中要运用I/O流对象对文件进行读写操作。

1.3 提供的基本管理功能有:

添加:即增加一条信息到设备信息中,或增加一条信息到实验室信息中;
显示:即在屏幕上显示所有设备或实验室信息;
存储:即将设备信息和实验室信息分别保存在文件中;
装入:即将文件中的信息读入程序;
查询:可根据设备名称查找具体情况,若找到,显示在屏幕上;
修改:可修改设备信息,或对实验室信息进行修改。
普通管理员的账户可以由vip管理员添加
vip 管理员账号:admin 密码:123456

实验设备管理系统

2. 代码实现

#include<iostream>
#include<string>
#include<cstring>
#include <iomanip>
#include <cstdlib>
#include<conio.h>
#include<fstream>
#include<windows.h>
using namespace std;
#define H "----------------------------------------------------------------\n"
#define H1 "|   编号    |     类别  |    名称    |    价格    |  库存数量  |\n"
#define H2 "|-----------|-----------|------------|------------|------------|\n"
#define H3 "--------------------------\n"
#define H4 "|   账号    |    密码    |\n"
#define H5 "|-----------|------------|\n"
class machine
{
public:
     machine();
	 machine(string a,string b,string c,double d,int e);
	 //char inter_face();//首页
     void add();//添加数据
     void dele();//删除数据
     void show();//显示所有
     void alter();//修改数据
     void select();//查询数据
     void save_new();//保存新增加数据
private:
	string num;
	string category;
	string name;
	double price;
	int quantity;
};
class account
{
public:
    account();
    char home_face();
	virtual void entrance();
   // void enter;
private:
    string id;
    string password;
};
class admin:public account
{
public:
   admin();
   virtual void admin_enter();
   void entrance();
private:
    string id;
    string password;
};
class vip:public admin
{
public:
	vip();
	void vip_enter();
	void entrance();
	void inter_face();//首页
    void add();//添加数据
    void dele();//删除数据
    void show();//显示所有
    void alter();//修改数据
    void select();//查询数据
    void save_new();//保存新增加数据
private:
    string id;
    string password;
};
machine::machine()
{
	 num=" ";
	 category=" ";
	 name=" ";
	 price=0;
	 quantity=0;
}
account::account()
{
	id=" ";
	password=" ";
}
admin::admin()
{
	id=" ";
	password=" ";
}
vip::vip()
{
	id="admin";
	password="123456";
}
void account::entrance()
{
	system("color 0b");
    char n;
    machine m;
	while(1)
	{
    system("cls");
    cout <<endl;
	cout<<"\t\t  O(∩_∩)O~~ 欢迎进入南阳康佳公司的设备管理系统\n\n";
    cout<<"\t\t╔*☆***◎***◇***☆*** 菜单 ***☆***◇***◎***☆*╗\n";
    cout<<"\t\t|★|\t\t               \t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t 1.设备信息显示\t\t\t|★|\n";
    cout<<"\t\t|☆|\t\t 2.设备信息查询\t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t 3.返回        \t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t               \t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
	cout<<"\t\t╚*☆***◎***◇****☆****★****☆****◇***◎***☆*╝\n\n";
    cout<<"\t\t请选择您要实现的功能选项 (1-3): [ ]\b\b";
	while(1)
	{
		cin>>n;getchar();
		if(n<'1'||n>'3')
			printf("输入错误,请您重新输入选项(1-3):[ ]\b\b");
		else
			break;
	}
	if(n=='1') {m.show();}
	if(n=='2') m.select();
	if(n=='3') return;
	}
}
void admin::admin_enter()
{
    string pp;
	char m;
	admin Admin;
	system("cls");
	cout<<endl<<endl<<endl;
	cout<<"\t\t O(∩_∩)O~~ 欢迎进入南阳康佳公司的设备管理系统\n\n\n";
   while(1)
   {
	ifstream inData("e:\\Document.txt",ios::in);
   cout<<"\t\t 请输入您的管理员账号:\n\t\t  (若返回上一个页面,请输入#号)"<<endl;
   cout<<"\t\t ";
   cin>>pp;
    if (!inData)
    {
        cout <<endl <<"\n对不起!账号不存在" <<endl;
        system("pause");
        return;
    }
   if(pp=="#") return;
    string qq;
    l:; cout<<"\t\t 请输入您的密码:\n";
    cout<<"\t\t ";
    while(1)
    {
       m=getch();
       if(m==13) break;
       if(m!=8) qq+=m;
       if(m==8) {cout<<endl;goto l;}
       cout<<"*";
    }
    bool flag =true;
    string str;
    while (inData>>id>>password)
    {
        getline(inData, str);
        if (id==pp)
        {
			flag = false;
			if(password==qq)
			{
                 Admin.entrance();
                 return;
			}
            else
             cout<<"\n\t\t    对不起!密码错误!!\n"<<endl;
        }
    }
    if(flag)
    {
        cout<<"\n\t\t    对不起!账号不存在!!\n"<<endl;
        //system("pause");
    }
 
   }
 
}
void vip::vip_enter()
{
   string pp;
   char m;
   vip VIP;
   admin Admin;
   system("cls");
   cout<<endl<<endl;
   cout<<"\t\t O(∩_∩)O~~ 欢迎进入南阳康佳公司的设备管理系统\n\n\n";
   while(1)
   {
   cout<<"\t\t   请输入您的vip管理员账号:\n\t\t     (若返回上一个页面,请输入#号)"<<endl;
   cout<<"\t\t   ";
   cin>>pp;
   getchar();
   if(pp=="#") return;
   if(pp==VIP.id)
   {
	   L:;cout<<"\t\t   请输入您的密码:"<<endl;
	   cout<<"\t\t   ";
       string qq;
       while(1)
       {
       m=getch();
       if(m==13) break;
       if(m!=8) qq+=m;
       if(m==8)
        {
            cout<<endl;goto L;
        }
       cerr<<"*";
       }
	   if(qq==VIP.password)
	   {
		   VIP.entrance();
		   break;
	   }
	   else
	   {
		  cout<<"\n\t\t    对不起!密码错误!!\n"<<endl;
	   }
   }
   else
   {
          cout<<"\t\t    对不起!账号不存在!!\n"<<endl;
   }
   }
}
void admin::entrance()
{
   system("color 0c");
   char n;
    machine Machine;
	account Account;
	while(1)
	{
    system("cls");
    cout <<endl;
	cout<<"\t\t  O(∩_∩)O~~ 欢迎进入南阳康佳公司的设备管理系统\n\n";
    cout<<"\t\t╔*☆***◎***◇***☆*** 菜单 ***☆***◇***◎***☆*╗\n";
    cout<<"\t\t|★|\t\t               \t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t 1.设备信息录入\t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t 2.设备信息显示\t\t\t|★|\n";
    cout<<"\t\t|☆|\t\t 3.设备信息查询\t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t 4.设备信息修改\t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t 5.设备信息删除\t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t 6.返回\t\t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
	cout<<"\t\t╚*☆***◎***◇****☆****★****☆****◇***◎***☆*╝\n\n";
    cout<<"\t\t请选择您要实现的功能选项 (1-6): [ ]\b\b";
	while(1)
	{
		cin>>n;getchar();
		if(n<'1'||n>'6')
			printf("输入错误,请您重新输入选项(1-6):[ ]\b\b");
		else
			break;
	}
    switch(n)
	{
    case '1':Machine.add();break;
	case '2':Machine.show();break;
	case '3':Machine.select();break;
	case '4':Machine.alter();break;
	case '5':Machine.dele();break;
    case '6':return;
	}
	}
}
void vip::entrance()
{
   system("color 0e");
    char n;
    machine Machine;
	vip VIP;
	while(1)
	{
    system("cls");
    cout <<endl;
	cout<<"\t\t  O(∩_∩)O~~ 欢迎进入南阳康佳公司的设备管理系统\n\n";
    cout<<"\t\t╔*☆***◎***◇***☆*** 菜单 ***☆***◇***◎***☆*╗\n";
    cout<<"\t\t|★|\t\t                    \t\t|★|\n";
	cout<<"\t\t|☆|\t\t1.设备信息录入      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t2.设备信息显示      \t\t|★|\n";
    cout<<"\t\t|☆|\t\t3.设备信息查询      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t4.设备信息修改      \t\t|★|\n";
	cout<<"\t\t|☆|\t\t5.设备信息删除      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t6.编辑管理员信息    \t\t|★|\n";
	cout<<"\t\t|★|\t\t7.返回              \t\t|★|\n";
	cout<<"\t\t|☆|\t\t                    \t\t|☆|\n";
	cout<<"\t\t╚*☆***◎***◇****☆****★****☆****◇***◎***☆*╝\n\n";
    cout<<"\t\t请选择您要实现的功能选项 (1-7): [ ]\b\b";
	while(1)
	{
		cin>>n;getchar();
		if(n<'1'||n>'7')
			printf("输入错误,请您重新输入选项(1-7):[ ]\b\b");
		else
			break;
	}
    switch(n)
	{
    case '1':Machine.add();break;
	case '2':Machine.show();break;
	case '3':Machine.select();break;
	case '4':Machine.alter();break;
	case '5':Machine.dele();break;
	case '6':VIP.inter_face();break;
    case '7':return;
	}
	}
}
void vip::inter_face()
{
   system("color 0c");
   char n;
    vip VIP;
	account Account;
	while(1)
	{
    system("cls");
    cout <<endl;
	cout<<"\t\t  O(∩_∩)O~~ 欢迎进入南阳康佳公司的设备管理系统\n\n";
    cout<<"\t\t╔*☆***◎***◇***☆*** 菜单 ***☆***◇***◎***☆*╗\n";
    cout<<"\t\t|★|\t\t                       \t\t|★|\n";
	cout<<"\t\t|☆|\t\t 1.管理员信息录入      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t 2.管理员信息显示      \t\t|★|\n";
    cout<<"\t\t|☆|\t\t 3.管理员信息查询      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t 4.管理员信息修改      \t\t|★|\n";
	cout<<"\t\t|☆|\t\t 5.管理员信息删除      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t 6.返回                \t\t|★|\n";
	cout<<"\t\t|☆|\t\t                       \t\t|☆|\n";
	cout<<"\t\t╚*☆***◎***◇****☆****★****☆****◇***◎***☆*╝\n\n";
    cout<<"\t\t请选择您要实现的功能选项 (1-6): [ ]\b\b";
	while(1)
	{
		cin>>n;getchar();
		if(n<'1'||n>'6')
			printf("输入错误,请您重新输入选项(1-6):[ ]\b\b");
		else
			break;
	}
    switch(n)
	{
    case '1':VIP.add();break;
	case '2':VIP.show();break;
	case '3':VIP.select();break;
	case '4':VIP.alter();break;
	case '5':VIP.dele();break;
    case '6':return;
	}
	}
}
void Get_xy(int x,int y)   //获取鼠标位置
{
    COORD pos;
    pos.X=x;
    pos.Y=y;
    HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(hout,pos);
}
char account::home_face()
{
	system("color 0d");
    char n;
    system("cls");
    cout <<endl;
 
    for(int i=0;i<9;i++)   //出现闪动效果
    {
    Get_xy(8,4);
	if(i%2==0)  cout<<"\t   O(∩_∩)O~~ 欢迎进入南阳康佳公司的设备管理系统\n\n";
	else cout<<endl<<endl;
    if(i%2==0) cout<<"\t\t╔*☆***◎***◇***☆*** 菜单 ***☆***◇***◎***☆*╗\n";
    else cout<<endl;
    cout<<"\t\t|★|\t\t               \t\t\t|★|\n";
	if(i%2==0) cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
    else cout<<endl;
	cout<<"\t\t|★|\t\t1.普通登录     \t\t\t|★|\n";
    cout<<"\t\t|☆|\t\t2.管理员登录   \t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t3.VIP管理员登录\t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t4.退出         \t\t\t|☆|\n";
    if(i%2==0)cout<<"\t\t|★|\t\t               \t\t\t|★|\n";
    else cout<<endl;
	cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
	if(i%2==0)cout<<"\t\t╚*☆***◎***◇****☆****★****☆****◇***◎***☆*╝\n\n";
	else cout<<endl<<endl;
    cout<<"\t\t请选择您要实现的功能选项 (1-4): [ ]\b\b";
    Sleep(50); if(i<8)system("cls");
    }
	while(1)
	{
		cin>>n;getchar();
		if(n<'1'||n>'4')
			printf("输入错误,请您重新输入选项(1-4):[ ]\b\b");
		else
			return n;
	}
}
//添加设备
void machine::add()
{
     char m;
     bool flag=true;
     ifstream inData("e:\\pbook.txt",ios::in);
     do
     {
    cout <<endl <<"根据下面提示添加新设备的信息" <<endl <<endl
        <<"编号 : " ;
    cin >>num;
    cout <<"类别 : ";
    do
    {
        cin >>category;
        if(category=="tv"||category=="dvd"||category=="tv_dvd") break;
        else
          cout<<"请输入tv或dvd或tv_dvd  " <<endl ;
    }while(1);
    cout <<"名称 : ";
    cin >>name;
    cout <<"价格 : ";
    cin >>price;
    cout <<"库存数量 : ";
    cin >>quantity;
    if (!inData)
    {
        flag=true;
    }
    string sign,str;
    while (inData>>sign)
    {
        getline(inData, str);
        if (num==sign)
        {
            flag = false;
        }
    }
    if(flag) save_new();
    else
    cout <<endl <<endl <<"设备编号已经存在,不能重复添加" <<endl <<endl;
    cout<<"\t是否继续添加?(y/n):[ ]\b\b";
    cin>>m;
    if(m=='n') break;
    }while(1);
}
//添加管理员
void vip::add()
{
     char m;
     bool flag=true;
     ifstream inData("e:\\Document.txt",ios::in);
     do
     {
    cout <<endl <<"根据下面提示添加新管理员的信息" <<endl <<endl
        <<"账号 : " ;
    cin >>id;
    cout<<"密码 : ";
    cin >>password;
    if (!inData)
    {
        flag=true;
    }
    string sign,str;
    while (inData>>sign>>str)
    {
        if (id==sign)
        {
            flag = false;
        }
    }
    if(flag) save_new();
    else
    cout <<endl <<endl <<"管理员号已经存在,不能重复添加" <<endl <<endl;
    cout<<"\t是否继续添加?(y/n):[ ]\b\b";
    cin>>m;
    if(m=='n') break;
    }while(1);
}
//删除设备
void machine::dele()
{
    ofstream outData("e:\\temp.txt", ios::out);
    ifstream inData("e:\\pbook.txt", ios::in);
    if (!inData)
    {
        cout <<endl <<"对不起!!!!找不到文件!!!!" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"你要删除设备的编号 :";
    cin >>sign;
    string str1;
    bool flag = true;
    string str;
    while(inData>>num)
    {
        getline(inData,str);
        if(sign==num)
        {
            cout <<endl <<"你想删除的设备:" <<endl <<endl;
			cout<<H<<H1<<H2;
            cout<<setw(10)<<num<<str<<endl;
	        cout<<H2;
            flag = false;
            break;
        }
        outData<<setiosflags(ios::left)<<num<<setw(10)<<str<<endl;
    }
    if (flag)
    {
        cout <<endl <<"对不起!!!没有你找的设备!!!!" <<endl <<endl;
    }
    else
    {
        while (getline(inData, str))
        {
            outData<<str<<endl;
        }
        outData.close();
        inData.close();
        ofstream out("e:\\pbook.txt", ios::out);
        ifstream in("e:\\temp.txt", ios::in);
        if (!out||!in)
        {
            cout <<endl <<"对不起,不能打开文件!!!" <<endl <<endl;
            system("pause");
            return;
        }
        while (getline(in,str))
        {
            out<<str<<endl;
        }
        out.close();
        in.close();
        cout <<endl <<"这个设备的信息已经删除!!!" <<endl <<endl;
    }
    system("pause");
}
//删除管理员
void vip::dele()
{
    ofstream outData("e:\\temp1.txt", ios::out);
    ifstream inData("e:\\Document.txt", ios::in);
    if (!inData)
    {
        cout <<endl <<"对不起!!!!找不到文件!!!!" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"你要删除管理员的帐号 :";
    cin >>sign;
    string str1;
    bool flag = true;
    string str;
    while(inData>>id)
    {
        getline(inData,str);
        if(sign==id)
        {
            cout <<endl <<"你想删除的管理员:" <<endl <<endl;
			cout<<H3<<H4<<H5;
            cout<<setw(10)<<id<<str<<endl;
			cout<<H5;
            flag = false;
            break;
        }
        outData<<setiosflags(ios::left)<<id<<setw(10)<<str<<endl;
    }
    if (flag)
    {
        cout <<endl <<"对不起!!!没有你找的管理员信息!!!!" <<endl <<endl;
    }
    else
    {
        while (getline(inData, str))
        {
            outData<<str<<endl;
        }
        outData.close();
        inData.close();
        ofstream out("e:\\Document.txt", ios::out);
        ifstream in("e:\\temp1.txt", ios::in);
        if (!out||!in)
        {
            cout <<endl <<"对不起,不能打开文件!!!" <<endl <<endl;
            system("pause");
            return;
        }
        while (getline(in,str))
        {
            out<<str<<endl;
        }
        out.close();
        in.close();
        cout <<endl <<"这个管理员的信息已经删除!!!" <<endl <<endl;
    }
    system("pause");
}
//显示所有信息
void machine::show()
{
    ifstream inData("e:\\pbook.txt",ios::in);
    if (!inData)
    {
        cout <<endl <<"对不起!!!!没有找到文件!!!!!" <<endl;
        system("pause");
        return;
    }
    bool flag = true;
    string record;
    while (getline(inData, record))
    {
        if (flag)
        {
            cout <<endl <<"所有设备信息如下: "<<endl;
			cout<<H<<H1<<H2;
        }
 
        cout <<record<<endl;
		cout<<H2;
        flag = false;
    }
 
    if (flag)
    {
        cout <<endl <<"系统中没有设备信息!!!!!" <<endl <<endl;
    }
    else
    {
        cout <<endl <<"所有设备信息已经全部显示出来!!!!!" <<endl <<endl;
    }
 
    system("pause");
}
void vip::show()
{
    ifstream inData("e:\\Document.txt",ios::in);
    if (!inData)
    {
        cout <<endl <<"对不起!!!!没有找到文件!!!!!" <<endl;
        system("pause");
        return;
    }
    bool flag = true;
    string record;
    while (getline(inData, record))
    {
        if (flag)
        {
            cout <<endl <<"所有管理员信息如下: "<<endl;
			cout<<H3<<H4<<H5;
        }
        cout <<record<<endl;
		cout<<H5;
        flag = false;
    }
 
    if (flag)
    {
        cout <<endl <<"系统中没有管理员信息!!!!!" <<endl <<endl;
    }
    else
    {
        cout <<endl <<"所有管理员信息已经全部显示出来!!!!!" <<endl <<endl;
    }
 
    system("pause");
}
//修改信息
void machine::alter()
{
    ofstream outData("e:\\temp.txt", ios::out);
    ifstream inData("e:\\pbook.txt", ios::in);
    if (!inData)
    {
        cout <<endl <<"对不起!!!!找不到文件!!!!" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"你要修改设备的编号 :";
    cin >>sign;
    bool flag = true;
    string str;
    while (inData>>num)
    {
        getline(inData, str);
        if (sign==num)
        {
            cout <<endl <<"你想修改的设备信息:" <<endl <<endl;
			cout<<H<<H1<<H2;
            cout<<setw(10)<<num<<str<<endl;
			cout<<H2;
            cout <<endl <<"请根据下面提示修改信息 : " <<endl;
            cout<<"编号 : " ;
            cin >>num;
            cout <<"类别 : ";
            cin >>category;
            cout <<"名称 : ";
            cin >>name;
            cout <<"价格 : ";
            cin >>price;
            cout <<"库存数量 : ";
            cin >>quantity;
            save_new();
            flag = false;
            break;
        }
        outData<<setiosflags(ios::left)<<num<<setw(10)<<str<<endl;
    }
    if (flag)
    {
        cout <<endl <<"对不起!!!没有找到这个设备!!!!" <<endl <<endl;
    }
    else
    {
        while(getline(inData, str))
        {
            outData <<str <<endl;
        }
        outData.close();
        inData.close();
        ofstream out("e:\\pbook.txt", ios::out);
        ifstream in("e:\\temp.txt", ios::in);
        if (!out||!in)
        {
            cout <<endl <<"对不起不能打开文件!!!" <<endl <<endl;
            system("pause");
            return;
        }
        while (getline(in, str))
        {
            out <<str <<endl;
        }
        out.close();
        in.close();
        cout <<endl <<"这个设备的信息已经修改!!!" <<endl <<endl;
    }
    system("pause");
}
void vip::alter()
{
    ofstream outData("e:\\temp1.txt", ios::out);
    ifstream inData("e:\\Document.txt", ios::in);
    if (!inData)
    {
        cout <<endl <<"对不起!!!!找不到文件!!!!" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"你要修改管理员的帐号 :";
    cin >>sign;
    bool flag = true;
    string str;
    while (inData>>id)
    {
        getline(inData, str);
        if (sign==id)
        {
            cout <<endl <<"你想修改的管理员信息:" <<endl <<endl;
			cout<<H3<<H4<<H5;
            cout<<setw(10)<<id<<str<<endl;
			cout<<H5;
            cout <<endl <<"请根据下面提示修改信息 : " <<endl;
            cout<<"帐号 : " ;
            cin >>id;
            cout <<"密码 : ";
            cin >>password;
            save_new();
            flag = false;
            break;
        }
        outData<<setiosflags(ios::left)<<id<<setw(10)<<str<<endl;
    }
    if (flag)
    {
        cout <<endl <<"对不起!!!没有找到这个管理员信息!!!!" <<endl <<endl;
    }
    else
    {
        while(getline(inData, str))
        {
            outData <<str <<endl;
        }
        outData.close();
        inData.close();
        ofstream out("e:\\Document.txt", ios::out);
        ifstream in("e:\\temp1.txt", ios::in);
        if (!out||!in)
        {
            cout <<endl <<"对不起不能打开文件!!!" <<endl <<endl;
            system("pause");
            return;
        }
        while (getline(in, str))
        {
            out <<str <<endl;
        }
        out.close();
        in.close();
        cout <<endl <<"这个设备的信息已经修改!!!" <<endl <<endl;
    }
    system("pause");
}
//查询设备
void machine::select()
{
    ifstream inData("e:\\pbook.txt",ios::in);
    if (!inData)
    {
        cout <<endl <<"对不起!文件找不到" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"输入你想查找的设备编号: ";
    cin >>sign;
    string str1;
    bool flag =true;
    string str;
    while (inData>>num)
    {
        getline(inData, str);
        if (num==sign)
        {
            cout <<endl <<"你要查找的设备是: " <<endl <<endl;
			cout<<H<<H1<<H2;
            cout <<setw(10)<<num<<str<<endl;
			cout<<H2;
            flag = false;
            system("pause");
            break;
        }
    }
    if(flag)
    {
        cout <<endl <<"你要查找的设备不存在!" <<endl <<endl;
        system("pause");
    }
}
void vip::select()
{
   ifstream inData("e:\\Document.txt",ios::in);
    if (!inData)
    {
        cout <<endl <<"对不起!文件找不到" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"输入你想查找的管理员帐号: ";
    cin >>sign;
    string str1;
    bool flag =true;
    string str;
    while (inData>>id)
    {
        getline(inData, str);
        if (id==sign)
        {
            cout <<endl <<"你要查找的管理员信息是: " <<endl <<endl;
			cout<<H3<<H4<<H5;
            cout<<setw(10)<<id<<str<<endl;
			cout<<H5;
            flag = false;
            system("pause");
            break;
        }
    }
    if(flag)
    {
        cout <<endl <<"你要查找的管理员信息不存在!" <<endl <<endl;
        system("pause");
    }
}
void machine::save_new()
{
    ofstream outData("e:\\pbook.txt", ios::app);
    if (!outData)
    {
        cout <<endl <<"对不起!!!打开文件失败!!!!" <<endl <<endl;
        system("pause");
        return;
    }
	outData	<<setw(10)<<num
        <<" " << setw(10) <<category <<" "
        <<setw(10)<< name <<" "
        <<setw(10)<<price<<" "
        <<setw(10)<<quantity
        <<endl;
    outData.close();
}
void vip::save_new()
{
    ofstream outData("e:\\Document.txt", ios::app);
    if (!outData)
    {
        cout <<endl <<"对不起!!!打开文件失败!!!!" <<endl <<endl;
        system("pause");
        return;
    }
    outData<<setw(10)<<id
        <<" " << setw(10) <<password <<" "<<endl;
    outData.close();
}
int main()
{
    machine Machine;
    account Account;
	admin Admin;
	vip VIP;
    while(1)
    {
      switch(Account.home_face())
      {
         case '1':Account.entrance();break;
	     case '2':Admin.admin_enter();break;
		 case '3':VIP.vip_enter();break;
		 case '4': MessageBox(NULL,"  Thanks for you!! \n\n \t\t---Made by hrdv \t  ","☆Bye☆Bye☆",0);return 0;//弹框
      }
    }
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
操作系统的定义:是一组控制和管理计算机软硬件资源,为用户提供便捷使用计算机的程序的集合。 基本功能:1.进程管理 2.存储管理 3.文件管理 4.设备管理 5.作业管理 基本组成: 1、驱动程序 最底层bai的、直接控制和监视各类硬件的部分,它du们的职zhi责是隐藏硬件的具体细节,并向dao其他部分提供一个抽象的、通用的接口。 2、内核 操作系统之最内核部分,通常运行在最高特权级,负责提供基础性、结构性的功能。 3、支承库(亦作“接口库”) 是一系列特殊的程序库,它们职责在于把系统所提供的基本服务包装成应用程序所能够使用的编程接口(API),是最靠近应用程序的部分。例如,GNU C运行期库就属于此类,它把各种操作系统的内部编程接口包装成ANSI C和POSIX编程接口的形式。 4、外围 所谓外围,是指操作系统中除以上三类以外的所有其他部分,通常是用于提供特定高级服务的部件。例如,在微内核结构中,大部分系统服务,以及UNIX/Linux中各种守护进程都通常被划归此列。 操作系统的分类:1.批处理系统 2.分时操作系统 3.实时操作系统 4.分布式操作系统 5.网络操作系统 6.嵌入式操作系统 操作系统的特点: 1、并发性: 是在计算机bai系统中同时存在多个程序,宏观上看,du这些程序是同时向前推进的。 在单CPU上,这些并发执行的程序是交替在CPU上运行的。 程序并发性体现在两个方面: 用户程序与用户程序之间的并发执行。 用户程序与操作系统程序之间的并发。 2、共享性: 资源共享是操作系统程序和多个用户程序共用系统中的资源。 3、 随机性: 随机性指:操作系统的运行是在一个随机的境中,一个设备可能在任何时间向处理机发出中断请求,系统无法知道运行着的程序会在什么时候做什么事情。 4、虚拟 (virtual)是指通过技术将一个物理实体变成若干个逻辑上的对应物。在操作系统中虚拟的实现主要是通过分时的使用方法。显然,如果n是某一个物理设备所对应的虚拟逻辑设备数,则虚拟设备的速度必然是物理设备速度的1/n。 5、异步性:不确定性。同一程序和数据的多次运行可能得到不同的结果;程序的运行时间、运行顺序也具有不确定性;外部输入的请求、运行故障发生的时间难以预测。这些都是不确定性的表现。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值