最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C++實(shí)現(xiàn)團(tuán)購(gòu)訂單管理系統(tǒng)

 更新時(shí)間:2022年12月30日 11:06:45   作者:派大星覺(jué)得我很聰明  
這篇文章主要為大家詳細(xì)介紹了如何利用C++實(shí)現(xiàn)團(tuán)購(gòu)訂單管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

項(xiàng)目需求

功能說(shuō)明

要求編寫(xiě)一個(gè)團(tuán)購(gòu)訂單信息管理系統(tǒng)。

系統(tǒng)包含對(duì)訂單的添加、查詢(xún)、修改、刪除和瀏覽等功能。

系統(tǒng)設(shè)有口令,只有正確輸入口令才能使用該信息管理系統(tǒng)

功能具體說(shuō)明

菜單的設(shè)計(jì):共設(shè)置6個(gè)選項(xiàng),包括訂單的添加、查詢(xún)、修改、刪除、瀏覽和退出。退出系統(tǒng)前菜單是重復(fù)循環(huán)的。

訂單信息的設(shè)計(jì):本案例采用簡(jiǎn)化形式,只定義了訂單編號(hào)、商品編號(hào)、商品單價(jià)、商品數(shù)量、收件人姓名等。

添加訂單:添加時(shí)訂單的詳細(xì)信息從鍵盤(pán)輸入相應(yīng)內(nèi)容。

瀏覽訂單:顯示當(dāng)前訂單的所有信息,要求有格式控制。

查詢(xún)訂單:可輸入訂單編號(hào)或收件人姓名查詢(xún)相應(yīng)訂單。

修改訂單:對(duì)特定訂單信息進(jìn)行修改并保存。

刪除訂單:可根據(jù)訂單編號(hào)對(duì)該訂單進(jìn)行刪除操作。

口令設(shè)置:被設(shè)為一個(gè)字符串常量。程序開(kāi)始運(yùn)行時(shí),要求通過(guò)鍵盤(pán)輸入口令。3次輸入不正確,直接結(jié)束程序。

代碼實(shí)現(xiàn)

對(duì)于訂單設(shè)計(jì)的類(lèi)

class Order

{

public:

       //構(gòu)造函數(shù)

       Order(string oid = "", string sid = "", double sp = 0, int sc = 0, string n 
= "")

       {

              order_num = oid;

              goods_num = sid;

              goods_price = sp;

              goods_count = sc;

              name = n;

       }



       //打印基本信息

       void print()

       {

              cout << "訂單編號(hào):" << setw(N) << order_num << " 商品編號(hào):" << 
setw(N) << goods_num << " 商品價(jià)格:"

                     << setw(N) << goods_price << " 商品數(shù)量:" << setw(N) << 
goods_count << " 收件人姓名:" << setw(N) << name << endl;

       }



       //獲得訂單編號(hào)

       string getOid()

       {

              return order_num;

       }



       //獲得姓名

       string getName()

       {

              return name;

       }



private:

       string order_num;    //訂單編號(hào)

       string goods_num;          //商品編號(hào)

       double goods_price;  //商品價(jià)格

       int goods_count;           //商品數(shù)量

       string name;         //收件人姓名

};

系統(tǒng)中各個(gè)功能的實(shí)現(xiàn)

對(duì)于系統(tǒng)中的添加,瀏覽,查詢(xún),修改,刪除五項(xiàng)功能分別定義了函數(shù)來(lái)實(shí)現(xiàn)。

其中的orders是用來(lái)保存訂單信息的數(shù)組,index是記錄當(dāng)前數(shù)組位置

void add(Order orders[], int& index)

{

       if (index == MAX)

       {

              cout << "訂單已滿(mǎn)" << endl;

              return;

       }



       string oid;

       string sid;

       double sp;

       int sc;

       string n;

       cout << "請(qǐng)輸入訂單編號(hào):";

       cin >> oid;

       cout << "請(qǐng)輸入商品編號(hào):";

       cin >> sid;

       cout << "請(qǐng)輸入商品價(jià)格:";

       cin >> sp;

       cout << "請(qǐng)輸入商品數(shù)量:";

       cin >> sc;

       cout << "請(qǐng)輸入收件人姓名:";

       cin >> n;

       Order o(oid, sid, sp, sc, n);

       orders[index++] = o;

       cout << "添加成功" << endl;

}



void visit(Order orders[], int& index)

{

       cout << "目前共有" << index << "個(gè)訂單" << endl;

       for (int i = 0; i < index; i++)

       {

              orders[i].print();

       }

}



void find(Order orders[], int& index)

{

       if (index == 0)

       {

              cout << "訂單為空" << endl;

       }



       int chiose;

       cout << "請(qǐng)選擇查詢(xún)方式  1、訂單編號(hào)  2、收件人姓名" << endl;

       cin >> chiose;

       if (chiose == 1)

       {

              string oid;

              cout << "請(qǐng)輸入要查詢(xún)的訂單編號(hào)" << endl;

              cin >> oid;

              for (int i = 0; i < index; i++)

              {

                     if (orders[i].getOid() == oid)

                     {

                           orders[i].print();

                     }

              }

       }

       else if (chiose == 2)

       {

              string name;

              cout << "請(qǐng)輸入要查詢(xún)的收件人姓名" << endl;

              cin >> name;

              for (int i = 0; i < index; i++)

              {

                     if (orders[i].getName() == name)

                     {

                           orders[i].print();

                     }

              }

       }

       else

       {

              cout << "錯(cuò)誤的選擇" << endl;

       }

}



void fixed(Order orders[], int& index)

{

       if (index == 0)

       {

              cout << "訂單為空" << endl;

       }



       string oid;

       cout << "請(qǐng)輸入要修改的訂單編號(hào)" << endl;

       cin >> oid;



       bool have = false;

       for (int i = 0; i < index; i++)

       {

              if (orders[i].getOid() == oid)

              {

                     have = true;



                     string oid;

                     string sid;

                     double sp;

                     int sc;

                     string n;

                     cout << "請(qǐng)輸入訂單編號(hào):";

                     cin >> oid;

                     cout << "請(qǐng)輸入商品編號(hào):";

                     cin >> sid;

                     cout << "請(qǐng)輸入商品價(jià)格:";

                     cin >> sp;

                     cout << "請(qǐng)輸入商品數(shù)量:";

                     cin >> sc;

                     cout << "請(qǐng)輸入收件人姓名:";

                     cin >> n;



                     Order o(oid, sid, sp, sc, n);

                     orders[i] = o;

              }

       }



       if (have == false)

       {

              cout << "沒(méi)有該訂單號(hào)的訂單" << endl;

              return;

       }

       cout << "修改成功" << endl;

}



void deleteOrder(Order orders[], int& index)

{

       if (index == 0)

       {

              cout << "訂單為空" << endl;

       }



       string oid;

       cout << "請(qǐng)輸入要?jiǎng)h除的訂單編號(hào)" << endl;

       cin >> oid;



       bool have = false;

       int i;

       for (i = 0; i < index; i++)

       {

              if (orders[i].getOid() == oid)

              {

                     have = true;

                     break;

              }

       }



       if (have == false)

       {

              cout << "沒(méi)有該訂單號(hào)的訂單" << endl;

              return;

       }

       else

       {

              for (int j = i; j < index - 1; j++)

              {

                     orders[j] = orders[j + 1];

              }

              index--;

       }



       cout << "刪除成功" << endl;

}

完整代碼

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

#define N 5

#define MAX 3 //最大訂單數(shù)量



class Order

{

public:

       //構(gòu)造函數(shù)

       Order(string oid = "", string sid = "", double sp = 0, int sc = 0, string n 
= "")

       {

              order_num = oid;

              goods_num = sid;

              goods_price = sp;

              goods_count = sc;

              name = n;

       }



       //打印基本信息

       void print()

       {

              cout << "訂單編號(hào):" << setw(N) << order_num << " 商品編號(hào):" << 
setw(N) << goods_num << " 商品價(jià)格:"

                     << setw(N) << goods_price << " 商品數(shù)量:" << setw(N) << 
goods_count << " 收件人姓名:" << setw(N) << name << endl;

       }



       //獲得訂單編號(hào)

       string getOid()

       {

              return order_num;

       }



       //獲得姓名

       string getName()

       {

              return name;

       }



private:

       string order_num;    //訂單編號(hào)

       string goods_num;          //商品編號(hào)

       double goods_price;  //商品價(jià)格

       int goods_count;           //商品數(shù)量

       string name;         //收件人姓名

};



Order orders[MAX];

int index = 0;



void add(Order orders[], int& index)

{

       if (index == MAX)

       {

              cout << "訂單已滿(mǎn)" << endl;

              return;

       }



       string oid;

       string sid;

       double sp;

       int sc;

       string n;

       cout << "請(qǐng)輸入訂單編號(hào):";

       cin >> oid;

       cout << "請(qǐng)輸入商品編號(hào):";

       cin >> sid;

       cout << "請(qǐng)輸入商品價(jià)格:";

       cin >> sp;

       cout << "請(qǐng)輸入商品數(shù)量:";

       cin >> sc;

       cout << "請(qǐng)輸入收件人姓名:";

       cin >> n;

       Order o(oid, sid, sp, sc, n);

       orders[index++] = o;

       cout << "添加成功" << endl;

}



void visit(Order orders[], int& index)

{

       cout << "目前共有" << index << "個(gè)訂單" << endl;

       for (int i = 0; i < index; i++)

       {

              orders[i].print();

       }

}



void find(Order orders[], int& index)

{

       if (index == 0)

       {

              cout << "訂單為空" << endl;

       }



       int chiose;

       cout << "請(qǐng)選擇查詢(xún)方式  1、訂單編號(hào)  2、收件人姓名" << endl;

       cin >> chiose;

       if (chiose == 1)

       {

              string oid;

              cout << "請(qǐng)輸入要查詢(xún)的訂單編號(hào)" << endl;

              cin >> oid;

              for (int i = 0; i < index; i++)

              {

                     if (orders[i].getOid() == oid)

                     {

                           orders[i].print();

                     }

              }

       }

       else if (chiose == 2)

       {

              string name;

              cout << "請(qǐng)輸入要查詢(xún)的收件人姓名" << endl;

              cin >> name;

              for (int i = 0; i < index; i++)

              {

                     if (orders[i].getName() == name)

                     {

                           orders[i].print();

                     }

              }

       }

       else

       {

              cout << "錯(cuò)誤的選擇" << endl;

       }

}



void fixed(Order orders[], int& index)

{

       if (index == 0)

       {

              cout << "訂單為空" << endl;

       }



       string oid;

       cout << "請(qǐng)輸入要修改的訂單編號(hào)" << endl;

       cin >> oid;



       bool have = false;

       for (int i = 0; i < index; i++)

       {

              if (orders[i].getOid() == oid)

              {

                     have = true;



                     string oid;

                     string sid;

                     double sp;

                     int sc;

                     string n;

                     cout << "請(qǐng)輸入訂單編號(hào):";

                     cin >> oid;

                     cout << "請(qǐng)輸入商品編號(hào):";

                     cin >> sid;

                     cout << "請(qǐng)輸入商品價(jià)格:";

                     cin >> sp;

                     cout << "請(qǐng)輸入商品數(shù)量:";

                     cin >> sc;

                     cout << "請(qǐng)輸入收件人姓名:";

                     cin >> n;



                     Order o(oid, sid, sp, sc, n);

                     orders[i] = o;

              }

       }



       if (have == false)

       {

              cout << "沒(méi)有該訂單號(hào)的訂單" << endl;

              return;

       }

       cout << "修改成功" << endl;

}



void deleteOrder(Order orders[], int& index)

{

       if (index == 0)

       {

              cout << "訂單為空" << endl;

       }



       string oid;

       cout << "請(qǐng)輸入要?jiǎng)h除的訂單編號(hào)" << endl;

       cin >> oid;



       bool have = false;

       int i;

       for (i = 0; i < index; i++)

       {

              if (orders[i].getOid() == oid)

              {

                     have = true;

                     break;

              }

       }



       if (have == false)

       {

              cout << "沒(méi)有該訂單號(hào)的訂單" << endl;

              return;

       }

       else

       {

              for (int j = i; j < index - 1; j++)

              {

                     orders[j] = orders[j + 1];

              }

              index--;

       }



       cout << "刪除成功" << endl;

}



int main(void)

{

       int n = 0;           //記錄口令輸入次數(shù)

       string password;                  //輸入的密碼

       cout << "請(qǐng)輸入登錄口令(默認(rèn)abcd)" << endl;

       while (1)

       {

              cin >> password;

              if (password == "abcd")

              {

                     cout << "輸入口令正確!" << endl;

                     break;

              }

              else

              {

                     cout << "輸入口令正確,請(qǐng)重新輸入!" << endl;

                     n++;

                     if (n == 3)

                     {

                           cout << "已輸入三次,您無(wú)權(quán)進(jìn)行操作!" << endl;

                           return 0;

                     }

              }

       }

       cout << endl;



       while (1)

       {

              system("cls");

              cout << "*******************************************" << endl;

              cout << "*     根據(jù)所做操作選擇一下數(shù)字序號(hào)        *" << endl;

              cout << "*     1.添加訂單        2.瀏覽訂單        *" << endl;

              cout << "*     3.查詢(xún)訂單        4.修改訂單        *" << endl;

              cout << "*     5.刪除訂單        6.退出系統(tǒng)        *" << endl;

              cout << "*******************************************" << endl;

              int n;

              cin >> n;

              switch (n)

              {

              case 1:

                     add(orders, index);

                     system("pause");

                     break;

              case 2:

                     visit(orders, index);

                     system("pause");

                     break;

              case 3:

                     find(orders, index);

                     system("pause");

                     break;

              case 4:

                     fixed(orders, index);

                     system("pause");

                     break;

              case 5:

                     deleteOrder(orders, index);

                     system("pause");

                     break;

              case 6:

                     return 0;

                     break;

              default:

                     break;

              }

       }



       return 0;

}

結(jié)語(yǔ)

該系統(tǒng)比較簡(jiǎn)單,對(duì)數(shù)據(jù)的存儲(chǔ)使用了數(shù)組,也可以使用順序表,鏈表等數(shù)據(jù)結(jié)構(gòu),代碼中也有很多值得優(yōu)化的地方。

以上就是C++實(shí)現(xiàn)團(tuán)購(gòu)訂單管理系統(tǒng)的詳細(xì)內(nèi)容,更多關(guān)于C++訂單管理系統(tǒng)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 深入理解c++常成員函數(shù)和常對(duì)象

    深入理解c++常成員函數(shù)和常對(duì)象

    下面小編就為大家?guī)?lái)一篇深入理解c++常成員函數(shù)和常對(duì)象。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧
    2016-05-05
  • C語(yǔ)言從代碼中加載動(dòng)態(tài)鏈接庫(kù)過(guò)程解析

    C語(yǔ)言從代碼中加載動(dòng)態(tài)鏈接庫(kù)過(guò)程解析

    這篇文章主要介紹了C語(yǔ)言從代碼中加載動(dòng)態(tài)鏈接庫(kù)過(guò)程解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-12-12
  • 深入了解C語(yǔ)言指針

    深入了解C語(yǔ)言指針

    這篇文章主要介紹了C語(yǔ)言指針詳解及用法示例,介紹了其相關(guān)概念,然后分享了幾種用法,具有一定參考價(jià)值。需要的朋友可以了解下
    2021-07-07
  • 最新評(píng)論

    伊宁县| 南溪县| 泗洪县| 潮安县| 乌海市| 大港区| 理塘县| 大洼县| 灵丘县| 静乐县| 宝应县| 九寨沟县| 泽普县| 农安县| 宜章县| 宝丰县| 康平县| 沙雅县| 新营市| 临城县| 辛集市| 西城区| 南和县| 全州县| 平顶山市| 中牟县| 昌图县| 大姚县| 沙湾县| 五指山市| 泸溪县| 宁城县| 大足县| 靖江市| 泸西县| 莆田市| 南投市| 盘锦市| 万载县| 大同市| 潞西市|