服装销售管理系统---课程设计(C/C++简易版)

目录

        基于大一学期对C/C++的学习做的一个关于实现一个服装销售管理系统的课程设计,强化自己关于面向对象(OOP)编程思想(耗时4~5天左右,功能大抵实现)。

        流程图:

         源代码:

         总结

        基于大一学期对C/C++的学习做的一个关于实现一个服装销售管理系统的课程设计,强化自己关于面向对象(OOP)编程思想(耗时4~5天左右,功能大抵实现)。

        流程图:

         源代码:

//#include "fdefine.h"  //引入含各函数定义的头文件
#include <iostream>
#include <bits/stdc++.h> //万能头文件include <fstream>  文件操作头文件
#include <windows.h>
using namespace std;
//采用类储存数据
class Goods_report;
class Administrator {  //管理员 
public:
    static int adnum;
    string ID;  //ID
    string password;  //密码
    //其他信息
    void setpassword(string pword);
}admin[100];
class Shopkeeper:public Administrator {   //店长公有继承管理员的数据ID与密码)   
public:
    //其他信息
    static int skp;
    void setpassword(string pword);
    void setID(string id);
}shopkeeper[100];
class Seller {  //销售员
public:
    static int snum;
    string ID1;     //营业ID号
    string name;   //姓名
    string ID2;    //所属店长ID号
    //goods* good;   //指向该销售员销售的商品信息
    //其他信息
}seller[100];
class Goods {       //商品           
public:
    static int gnum;
    string name;    //商品名
    string code;     //商品代码
    string producer;  //制造商
    float price; //价格
    friend void print(Goods&a,Goods_report&b);
}goods[100];
class Goods_report { //商品报表
public:
    static int rnum;
    string name;     //商品
    float num;         //商品销售数量
    float money;       //商品销售总额
    void set(float x, float y);
    Goods_report operator+(Goods_report& temp);
    Goods_report operator++();
}report1[100], report2[100];
//初始化各个类的静态变量
int Administrator::adnum = 0;
int Shopkeeper::skp = 0;
int Seller::snum = 0;
int Goods::gnum = 0;
int Goods_report::rnum = 0;
//系统函数
void Delay(int time){
    clock_t  now = clock();
    while (clock() - now < time);
}
void pcout(char x) {
    int i;
    cout << "\t\t\t\t";
    for (i = 0; i < 62; i++) {
        Delay(4);   cout << x;
    }
    cout << '\n';
}
void start() {
    int i;
    cout << "加载中,请稍后";
    for (i = 0; i < 80; i++) {
        Delay(10);   //需要#include<windows.h>
        cout << ".";      
    }
    system("cls");  //清屏
}
//管理员类函数
void Administrator::setpassword(string pword) {
    this->password = pword;
}
//店长类函数
void Shopkeeper::setpassword(string pword) {
    this->password = pword;
}
void Shopkeeper::setID(string id) {
    this->ID = id;
}
//商品信息的函数(含友元函数)
void Goods_report::set(float x, float y) {
    this->num = x;
    this->money = y;
}
void print(Goods& a, Goods_report& b) {
    Delay(7);    cout << "\t\t\t\t" << "该商品的名称为:" << a.name << endl;
    Delay(7);    cout << "\t\t\t\t该商品的制作商为:" << a.producer << endl;
    Delay(7);    cout << "\t\t\t\t该商品的价格为:$" << a.price << endl;
    Delay(7);    cout << "\t\t\t\t" << "该商品的日销售量为:" << b.num << endl;
    Delay(7);    cout << "\t\t\t\t该商品的日销售额为:$" << b.money << endl;
}
Goods_report Goods_report::operator+(Goods_report& temp) {
    Goods_report t;
    t.num = num + temp.num;
    t.money = money + temp.money;
    return t;
}
Goods_report Goods_report::operator++() {
    num++;
    return *this;
}
//从文件中导入数据函数
void inp1(Administrator* p1) {   //管理员模块文件输入
    ifstream infile1("Admin.txt");
    string aID, apassword;
    while (!infile1.eof()) {
        infile1 >> aID >> apassword;
        p1[Administrator::adnum].ID = aID;
        p1[Administrator::adnum].password = apassword;
        Administrator::adnum++;
    }
    infile1.close();
}
void inp2(Shopkeeper* p2) {  //店员模块文件输入
    ifstream infile2("Shopkeeper.txt");
    string bID, bpassword;
    while (!infile2.eof()) {
        infile2 >> bID >> bpassword;
        p2[Shopkeeper::skp].ID = bID;
        p2[Shopkeeper::skp].password = bpassword;
        Shopkeeper::skp++;
    }
    infile2.close();
}
void inp3(Seller* p3) {
    ifstream infile3("Seller.txt");
    string cID1, cname, cID2;
    while (!infile3.eof()) { //销售员模块文件输入
        infile3 >> cID1 >> cname >> cID2;
        p3[Seller::snum].ID1 = cID1;
        p3[Seller::snum].name = cname;
        p3[Seller::snum].ID2 = cID2;
        Seller::snum++;
    }
    infile3.close();
}
void inp4(Goods* p4) { //服装商品模块文件写入
    ifstream infile4("Goods.txt");
    string gname, gcode, gproducer;
    float gprice;
    while (!infile4.eof()) {
        infile4 >> gname >> gcode >> gproducer >> gprice;
        p4[Goods::gnum].name = gname;
        p4[Goods::gnum].code = gcode;
        p4[Goods::gnum].producer = gproducer;
        p4[Goods::gnum].price = gprice;
        Goods::gnum++;
    }
    infile4.close();
}
void inp5(Goods_report* p5, Goods_report* p6) {
    ifstream infile5("Goods_reportday.txt");
    ifstream infile6("Goods_reportmonth.txt");
    string rname;
    float rn, rmoney;
    while (!infile5.eof()) {
        infile5 >> rname >> rn >> rmoney;
        p5[Goods_report::rnum].name = rname;
        p5[Goods_report::rnum].num = rn;
        p5[Goods_report::rnum].money = rmoney;
        infile6 >> rname >> rn >> rmoney;
        p6[Goods_report::rnum].name = rname;
        p6[Goods_report::rnum].num = rn;
        p6[Goods_report::rnum].money = rmoney;
        Goods_report::rnum++;
    }
    infile5.close();
    infile6.close();
}
//文件中做出本次操作修改函数
void outp(Administrator* r1,int n1) {
    ofstream out1("Admin.txt");
    int i;
    for (i = 0; i < n1-1; i++) {
        out1 << r1->ID << " " << r1->password << endl;
        r1++;
    }
    out1.close();
}
void outp(Shopkeeper* r2, int n2) {
    ofstream out2("Shopkeeper.txt");
    int i;
    for (i = 0; i < n2-1; i++) {
        out2 << r2->ID << " " << r2->password << endl;
        r2++;
    }
    out2.close();
}
void outp(Seller* r3, int n3) {
    ofstream out3("Seller.txt");
    int i;
    for (i = 0; i < n3-1; i++) {
        out3 << r3->ID1 << " " << r3->name << " " << r3->ID2 << endl;
        r3++;
    }
    out3.close();
}
void outp(Goods* r4, int n4) {
    ofstream out4("Goods.txt");
    int i;
    for (i = 0; i < n4-1; i++) {
        out4 << r4->name << " " << r4->code << " " << r4->producer << " " << r4->price << endl;
        r4++;
    }
    out4.close();
}
void outp(Goods_report* r5, Goods_report* r6, int n5) {
    ofstream out5("Goods_reportday.txt");
    ofstream out6("Goods_reportmonth.txt");
    int i;
    for (i = 0; i < n5; i++) {
        out5 << r5->name << " " << r5->num << " " << r5->money << endl;
        out6 << r6->name << " " << r6->num << " " << r6->money << endl;
        r5++;
        r6++;
    }
    out5.close();
    out6.close();
}
void sort(Goods *gp,int n) {
    int i, j;
    for (i = 0; i < n - 2; i++)
        for (j = i + 1; j < n - 1; j++)
            if ((gp + i)->code > (gp + j)->code) {
                string t1;
                float t2;
                t1 = (gp + i)->code;
                (gp + i)->code = (gp + j)->code;
                (gp + j)->code = t1;
                t1 = (gp + i)->name;
                (gp + i)->name = (gp + j)->name;
                (gp + j)->name = t1;
                t1 = (gp + i)->producer;
                (gp + i)->producer = (gp + j)->producer;
                (gp + j)->producer = t1;
                t2 = (gp + i)->price;
                (gp + i)->price = (gp + j)->price;
                (gp + j)->price = t2;
            }
}
//不同模块操作函数定义
void changeA(Administrator* p11, int k) {
    string newpassword;
    Delay(7);    cout << "\t\t\t\t" << "请输入您的新密码:";
    cin >> newpassword;
    Delay(7);    p11[k].setpassword(newpassword);    cout << "\t\t\t\t" << "密码修改成功!!!" << endl;
}
void changeS(Shopkeeper* p55, int k) {
    string newpassword;
    Delay(7);    cout << "\t\t\t\t" << "请输入您的新密码:";
    cin >> newpassword;
    p55[k].setpassword(newpassword);
    Delay(7);    cout << "\t\t\t\t" << "密码修改成功!!!" << endl;
}
void addadmin(Administrator* p1) {
    string nID, npassword;
    Delay(7);    cout << "\t\t\t\t" << "请输入新管理员的ID和密码..." << endl;
    Delay(7);    cout << "\t\t\t\t" << "ID:";
    cin >> nID;
    Delay(7);    cout << "\t\t\t\t" << "密码:";
    cin >> npassword;
    p1[Administrator::adnum].ID = nID;
    p1[Administrator::adnum].password = npassword;
    Administrator::adnum++;
    Delay(7);    cout << "\t\t\t\t" << "添加管理员成功!!!" << endl;
}
void addskp(Shopkeeper* p2) {
    string nID, npassword;
    Delay(7);    cout << "\t\t\t\t" << "请输入新销售员的ID和密码..." << endl;
    Delay(7);    cout << "\t\t\t\t" << "ID:";
    cin >> nID;
    Delay(7);    cout << "\t\t\t\t" << "密码:";
    cin >> npassword;
    p2[Shopkeeper::skp].ID = nID;
    p2[Shopkeeper::skp].password = npassword;
    Shopkeeper::skp++;
    Delay(7);    cout << "\t\t\t\t" << "添加店员成功!!!" << endl;
}
void addseller(Seller* p3) {
    string nID1, nID2, nname;
    Delay(7);    cout << "\t\t\t\t" << "请输入新销售员的ID1(所属管理员ID)、ID2和姓名..." << endl;
    Delay(7);    cout << "\t\t\t\t" << "ID1(所属管理员ID):";
    cin >> nID1;
    Delay(7);    cout << "\t\t\t\t" << "ID1(所属店员ID):";
    cin >> nID2;
    Delay(7);    cout << "\t\t\t\t" << "姓名:";
    cin >> nname;
    p3[Seller::snum].ID1 = nID1;
    p3[Seller::snum].ID1 = nID2;
    p3[Seller::snum].name = nname;
    Seller::snum++;
    Delay(7);    cout << "\t\t\t\t" << "添加销售员成功!!!" << endl;
}
void printadmin(Administrator* p33) {
    system("cls");
    cout << "\n\n\n\n";
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "*              管理员ID                用户密码              *\n";
    int a;
    for (a = 0; a < Administrator::adnum - 1; a++) {
        Delay(7);   cout << "\t\t\t\t" << "                " << std::left << setw(24) << p33[a].ID << p33[a].password << endl;
    }
    pcout('*');
}
void printgoods(Goods* p44) {
    system("cls");
    cout << "\n\n\n\n";
    pcout('-');
    Delay(7);    cout << "\t\t\t\t" << "| 商品名          商品代码        商品制造商         商品价格 |" << endl;
    int a;
    for (a = 0; a < Goods::gnum - 1; a++) {
        Delay(7);    cout << "\t\t\t\t" << std::left << setw(21) << p44[a].name << setw(17) << p44[a].code << setw(17) << p44[a].producer << p44[a].price << endl;
        pcout('-');
    }
}
void Sprintgoods(Goods* p44) {
    system("cls");
    int a;
    for (a = 0; a < Goods::gnum - 1; a++) {
        cout << "\n\n\n\n";
        Delay(7);    cout << "\t\t\t\t" << "商品名:    " << p44[a].name << endl;
        cout << '\n';
        Delay(7);    cout << "\t\t\t\t" << "商品代码:  " << p44[a].code << endl;
        cout << '\n';
        Delay(7);    cout << "\t\t\t\t" << "商品制造商:" << p44[a].producer << endl;
        cout << '\n';
        Delay(7);    cout << "\t\t\t\t" << "商品价格:  " << p44[a].price << endl;
        cout << "\t\t\t\t";
        system("pause");
        system("cls");
    }
}
void printtype() {
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "*                          查看方式                          *\n";
    Delay(7);    cout << "\t\t\t\t" << "********         1.单屏输出        2.多屏输出         ********\n";
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "请输入:";
    int v;
    cin >> v; 
    cout << '\n';
    if (v == 1) 
        printgoods(goods);
    else 
        Sprintgoods(goods);
}
void printreport(Goods_report* p77) {
    pcout('*');
    cout << '\n';
    Delay(7);    cout << "\t\t\t\t" << "* 商品名                   销售数量                 总销售额 *" << endl;
    int a;
    for (a = 0; a < Goods_report::rnum; a++) {
        Delay(7);    cout << "\t\t\t\t" << std::left << setw(31) << p77[a].name << setw(23) << p77[a].num << "$" << p77[a].money << endl;
    }
    pcout('*');
}
void printreserve() {
    system("cls");
    cout << "\n\n\n\n";
    pcout('-');
    Delay(7);    cout << "\t\t\t\t" << "| 商品编号                   商品名称                储备数量 |" << endl;
    ifstream fin("Goodsreserve.txt");
    int rid;
    string rename, renum;
    while (!fin.eof()) {
        fin >> rid >> rename >> renum;
        Delay(7);    cout << "\t\t\t\t     " << std::left << setw(24) << rid << setw(25) << rename << "$" << renum << endl;
        pcout('-');
    }
    fin.close();
}
void setskp(Shopkeeper* p66, int k) {
    string nID, npassword;
    Delay(7);    cout << "\t\t\t\t" << "请输入您的新ID和新密码..." << endl;
    Delay(7);    cout << "\t\t\t\t" << "新ID:";
    cin >> nID;
    Delay(7);    cout << "\t\t\t\t" << "新密码:";
    cin >> npassword;
    p66[k].setID(nID);
    p66[k].setpassword(npassword);
    Delay(7);    cout << "\t\t\t\t" << "修改成功!!!" << endl;
}
//登陆菜单界面函数,采用循环式登录方式
int log() { 
    while (1) {
        pcout('*');
        Delay(7);    cout << "\t\t\t\t" << "*                  欢迎进入服装销售系统!                    *\n";
        pcout('*');
        Delay(7);    cout << "\t\t\t\t" << "*                   请选择您的登录身份...                    *\n";
        Sleep(50);    cout << "\t\t\t\t" << "*                                                            *\n";
        Delay(7);
        Delay(7);    cout << "\t\t\t\t" << "*************      1.管理员       2.店员      ****************\n";
        Delay(7);    cout << "\t\t\t\t" << "*************      3.销售员       4.退出      ****************\n";
        pcout('*');
        Delay(7);    cout << "\t\t\t\t" << "请选择:";
        string x;
        cin >> x;
        cout << '\n';
        if (x == "1") 
            return 1;
        else if (x == "2") 
            return 2;
        else if (x == "3") 
            return 3;
        else if (x == "4") 
            return 4;
        try {
            if (x != "1" && x != "2" && x != "3" && x != "4") {
                throw runtime_error("您的输入有误,请输入正确的选项(1/2/3/4),正在为您重新进入系统......."); // 抛出异常
            }  
        }// 执行相应操作
        catch (runtime_error& e) { // 捕获异常,并输出错误信息
            Delay(7);    cout << "\t\t\t\t" << "错误信息:" << e.what() << endl;
            Delay(7);    cout << "\n\n\n\n";
            system("cls");
        }
    }
}
int cb() {
    cout << '\n';
    cout << '\n';
    cout << "\t\t\t\t";
    system("pause");
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "*                     请选择您的下一步操作                   *\n";
    Delay(7);    cout << "\t\t\t\t" << "**************    1.返回         2.退出         **************\n";
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "请输入:";
    int v;
    cin >> v;
    cout << '\n';
    return v;
}
void save() {
    system("cls");
    cout << "\n\n\n"; 
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "*                        是否保存数据                        *\n";
    Delay(7);    cout << "\t\t\t\t" << "**************         1.是        2.否         **************\n";
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "请输入:";
    int v;
    cin >> v;
    cout << '\n';
    if (v == 1) {
        outp(admin, Administrator::adnum);
        outp(shopkeeper, Shopkeeper::skp);
        outp(seller, Seller::snum);
        outp(goods, Goods::gnum);
        outp(report1, report2, Goods_report::rnum);
    }
}
void typestyle() {
    inp1(admin); 
    inp2(shopkeeper); 
    inp3(seller); 
    inp4(goods); 
    inp5(report1, report2);
    sort(goods, Goods::gnum - 1); //根据商品编号冒泡排序
    start();
    while (1) {
        int type; //记录用户登录方式
        type = log();
        //管理员模块********************
        if (type == 1) {
            Delay(7);    cout << "\t\t\t\t" << "您选择的登录方式是管理员..." << endl;
            Delay(7);    cout << "\t\t\t\t" << "请输入您的ID和密码..." << endl;
            string id1, password1;
            Delay(7);    cout << "\t\t\t\t" << "ID:";
            cin >> id1;
            Delay(7);    cout << "\t\t\t\t" << "密码:";
            cin >> password1;
            int i, leap = 0, pot;
            for (i = 0; i < Administrator::adnum - 1; i++) {
                if (admin[i].ID == id1 && admin[i].password == password1) {
                    leap = 1;
                    pot = i;
                    break;
                }
            }
            if (leap == 0) {
                Delay(7);    cout << "\t\t\t\t" << "抱歉,输入的用户名或密码错误!没有找到您的信息...正在返回..." << endl;
                cout << "\n\n\n";
                system("pause");
                system("cls");
                continue;
            }
            else {
                int style;
                cout << '\n';
                system("cls");
                cout << "\n\n\n\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "*                 欢迎进入,请选择您的下一步操作             *\n";
                Delay(7);    cout << "\t\t\t\t" << "*                                                            *\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    1.修改密码     2.添加用户     **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    3.管理员信息   4.商品信息     **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    5.返回         6.退出         **************\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "请选择:";
                cin >> style;
                cout << '\n';
                if (style == 1) {
                    changeA(admin, pot);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 2) {
                    pcout('*');
                    Sleep(200);    cout << "\t\t\t\t" << "*              请选择添加管理员、店员还是销售员:             *\n";
                    Sleep(200);    cout << "\t\t\t\t" << "*             1.管理员      2.店员       3.销售员            *\n";
                    pcout('*');
                    Sleep(200);    cout << "\t\t\t\t" << "请选择:";
                    int kk;
                    cin >> kk;
                    cout << '\n';
                    switch (kk) {
                    case 1:
                        addadmin(admin);
                        break;
                    case 2:
                        addskp(shopkeeper);
                        break;
                    case 3:
                        addseller(seller);
                        break;
                    }
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 3) {
                    printadmin(admin);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 4) {
                    printtype();
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 5) {
                    system("cls");
                    continue;
                }
                else if (style == 6) {
                    system("cls");
                    break;
                }
            }
        }
        //店员模块**********************
        else if (type == 2) {
            Delay(7);    cout << "\t\t\t\t" << "您选择的登录方式是店员..." << endl;
            Delay(7);    cout << "\t\t\t\t" << "请输入您的ID和密码..." << endl;
            string id, password;
            Delay(7);    cout << "\t\t\t\t" << "ID:";
            cin >> id;
            Delay(7);    cout << "\t\t\t\t" << "密码:";
            cin >> password;
            int i, leap = 0, pot;
            for (i = 0; i < Shopkeeper::skp - 1; i++) {
                if (shopkeeper[i].ID == id && shopkeeper[i].password == password) {
                    leap = 1;
                    pot = i;
                    break;
                }
            }
            if (leap == 0) {
                cout << "\t\t\t\t" << "抱歉,输入的用户名或密码错误!没有找到您的信息...正在返回..." << endl;
                system("pause");
                system("cls");
                continue;
            }
            else {
                int style;
                cout << '\n';
                system("cls");
                cout << "\n\n\n\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "*                   欢迎进入,请选择您的下一步操作           *\n";
                Delay(7);    cout << "\t\t\t\t" << "*                                                            *\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    1.修改密码     2.修改个人信息 **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    3.商品信息     4.查看报表     **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    5.商品储备信息 6.商品销量情况 **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    7.返回         8.退出         **************\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "请选择:";
                cin >> style;
                cout << '\n';
                if (style == 1) {
                    changeS(shopkeeper, pot);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 2) {
                    setskp(shopkeeper, pot);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 3) {
                    printtype();
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 4) {
                    system("cls");
                    cout << "\n\n\n\n";
                    pcout('*');
                    Delay(7);    cout << "\t\t\t\t" << "*                            本日报表                        *\n";
                    cout << "\t\t\t\t" << "*                        日期:2023年6月7日                  *\n";
                    printreport(report1);
                    pcout('*');
                    Delay(7);    cout << "\t\t\t\t" << "*                            本月报表                        *\n";
                    Delay(7);    cout << "\t\t\t\t" << "*                         日期:2023年6月                    *\n";
                    printreport(report2);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 5) {
                    printreserve();
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 6) {
                    system("cls");
                    cout << "\n\n\n";
                    int ii;
                    Goods_report temp1, temp2;
                    temp1.set(0, 0);
                    temp2.set(0, 0);
                    for (ii = 0; ii < Goods_report::rnum - 1; ii++) {
                        temp1 = temp1 + report1[ii];
                        temp2 = temp2 + report2[ii];
                    }
                    pcout('*');
                    Delay(7);    cout << "\t\t\t\t" << "*            本日总销售量            本日销售总额            *\n";
                    Delay(7);    cout << "\t\t\t\t" << std::left << "                 " << setw(24) << temp1.num << temp1.money << endl;
                    Delay(7);    cout << "\t\t\t\t" << "*            本月总销售量            本月销售总额            *\n";
                    Delay(7);    cout << "\t\t\t\t" << std::left << "                 " << setw(24) << temp2.num << temp2.money << endl;
                    pcout('*');
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 7) {
                    system("cls");
                    continue;
                }
                else if (style == 8) {
                    system("cls");
                    break;
                }   
            }
        }
        //销售员模块********************
        else if (type == 3) {
            Delay(7);    cout << "\t\t\t\t" << "您选择的登录方式是销售员..." << endl;
            Delay(7);    cout << "\t\t\t\t" << "请输入您的姓名、营业号ID和所属店长ID号..." << endl;
            string sname, id1, id2;
            Delay(7);    cout << "\t\t\t\t" << "姓名:";
            cin >> sname;
            Delay(7);    cout << "\t\t\t\t" << "营业号ID:";
            cin >> id1;
            Delay(7);    cout << "\t\t\t\t" << "所属店长ID号:";
            cin >> id2;
            int i, leap = 0, pot;
            for (i = 0; i < Seller::snum - 1; i++) {
                if (seller[i].name == sname && seller[i].ID1 == id1 && seller[i].ID2 == id2) {
                    leap = 1;
                    pot = i;
                    break;
                }
            }
            if (leap == 0) {
                Delay(7);    cout << "抱歉,输入的信息错误!没有找到您的信息...正在返回..." << endl;
                system("pause");
                system("cls");
                continue;
            }
            else {
                int style;
                system("cls");
                cout << '\n';
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "*                 欢迎进入,请选择您的下一步操作             *\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "*                                                            *\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    1.商品浏览     2.查找商品     **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    3.出售商品     4.查看报表     **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    5.返回         6.退出         **************\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "请选择:";
                cin >> style;
                cout << '\n';
                if (style == 1) {
                    printtype();
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 2) {
                    Delay(7);    cout << "\t\t\t\t" << "请输入您想要查找的商品编号:";
                    string shopcode;
                    cin >> shopcode;
                    cout << '\n';
                    int si, spot, sleap = 0;
                    for (si = 0; si < Goods::gnum - 1; si++) {
                        if (goods[si].code == shopcode) {
                            sleap = 1;
                            spot = si;
                            break;
                        }
                    }
                    if (sleap == 0) {
                        Delay(7);    cout << "\t\t\t\t" << "抱歉,没有找到该商品的信息...正在返回上级菜单..." << endl;
                        system("cls");
                        continue;
                    }
                    else {
                        print(goods[spot],report1[spot]);
                        int vv = cb();
                        if (vv == 1) {
                            system("cls");
                            continue;
                        }
                        else {
                            system("cls");
                            break;
                        }
                    }
                }
                else if (style == 3) {
                    Delay(7);    cout << "\t\t\t\t" << "请输入您想要出售的商品编号:";
                    string shopcode;
                    cin >> shopcode;
                    int si, spot, sleap = 0;
                    for (si = 0; si < Goods::gnum - 1; si++) {
                        if (goods[si].code == shopcode) {
                            sleap = 1;
                            spot = si;
                            break;
                        }
                    }
                    if (sleap == 0) {
                        Delay(7);    cout << "抱歉,没有找到该商品的信息...正在返回上级菜单..." << endl;
                        system("cls");
                        continue;
                    }
                    else {
                        ++report1[spot];
                        report1[spot].money += goods[spot].price;
                        ++report2[spot];
                        report2[spot].money += goods[spot].price;  //测试cout << report1[spot].money << " " << report1[spot].num;
                        Delay(7);    cout << "\t\t\t\t" << "出售成功!!!您出售了" << goods[spot].name << endl;
                        int vv = cb();
                        if (vv == 1) {
                            system("cls");
                            continue;
                        }
                        else {
                            system("cls");
                            break;
                        }
                    }
                }
                else if (style == 4) {
                    pcout('*');
                    Delay(7);    cout << "\t\t\t\t" << "*                            本日报表                        *\n";
                    Delay(7);    cout << "\t\t\t\t" << "*                        日期:2023年6月7日                  *\n";
                    printreport(report1);
                    pcout('*');
                    Delay(7);    cout << "\t\t\t\t" << "*                            本月报表                        *\n";
                    Delay(7);    cout << "\t\t\t\t" << "*                         日期:2023年6月                    *\n";
                    printreport(report2);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 5) {
                    system("cls");
                    continue;
                }
                else if (style == 6) {
                    system("cls");
                    break;
                }
            }
        }
        else if (type == 4) {
            system("cls");
            break;
        }     
    }
    save();
    Delay(7);    cout << "\t\t\t\t" << "****************欢迎下次使用本系统!!!谢谢!!**************\n";
}
int main(){  
    system("color EA");
    typestyle();
    return 0;
}

         代码运行视频见发布视频live.csdn.net/v/306329

         总结

        在课程设计中,不仅学习了C++语言的基础知识,还学习了如何运用C++语言进行面向对象的编程设计。通过本次实验,进一步理解了面向对象程序设计的基本思想与方法,提高了我的程序设计和编程能力。编程之路,道阻且长!

  • 1
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
数据结构课程设计c/c++--美团餐馆预定信息的管理与分析。 本课程设计旨在设计一个C/C++程序,用于管理和分析美团餐馆的预定信息。通过合理的数据结构设计和算法编程,实现对餐馆的预定信息进行管理和分析,以提高用户的预定体验和餐馆的效益。 首先,需要设计合适的数据结构来存储餐馆的预定信息。可以利用链表、数组、队列等数据结构来存储餐馆的基本信息(如名称、地址、电话等)和预定信息(如预定日期、预定时间、预定人数等)。通过数据结构的合理选择和设计,能够提高程序的运行效率和数据的访问速度。 其次,需要设计相应的功能模块来管理餐馆的预定信息。包括添加餐馆信息、查询餐馆信息、预定餐馆、取消预定等功能。通过各个功能模块之间的有机组合和调用,能够实现对预定信息的全面管理和操作。 最后,需要设计一些算法来进行预定信息的分析。可以通过统计预定信息的频次、根据用户的偏好推荐适合的餐馆等方法,对预定信息进行分析和挖掘。这样可以从大量的数据中挖掘出有价值的信息,进一步提高餐馆的运营策略和用户的预定体验。 通过本课程设计,不仅能够提高学生对数据结构的理解和应用能力,还能够锻炼学生的问题分析和解决能力。同时,也能够为美团等餐饮平台提供有价值的参考和借鉴。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

想我记得写信

您的鼓励是我创作最大的动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值