m0_68946274 2023-02-05 12:46 采纳率: 100%
浏览 57
已结题

失物招领系统详细设计

数据结构与算法结课设计项目失物招领系统详细设计
1、设计抽象数据类型对应的类定义。
2、设计每个成员函数;
3、设计主函数

img

  • 写回答

4条回答 默认 最新

  • CodeBytes 2023-02-05 12:59
    关注

    大项目,不是一下子搞得定的

    该回答引用ChatGPT
    请参考下面的解决方案,如果可行还请点击 采纳,感谢!

    1、设计抽象数据类型对应的类定义,C++代码:

    class LostAndFound {
    public:
        LostAndFound();
        ~LostAndFound();
    
        void addLostItem(string itemName, string itemDesc);
        void addFoundItem(string itemName, string itemDesc);
        void claimLostItem(string itemName);
        void listLostItems();
        void listFoundItems();
    
    private:
        struct Item {
            string name;
            string desc;
            bool claimed;
        };
    
        vector<Item> lostItems;
        vector<Item> foundItems;
    };
    
    
    

    2、设计每个成员函数:

    LostAndFound::LostAndFound() {}
    
    LostAndFound::~LostAndFound() {}
    
    void LostAndFound::addLostItem(string itemName, string itemDesc) {
        Item item;
        item.name = itemName;
        item.desc = itemDesc;
        item.claimed = false;
        lostItems.push_back(item);
    }
    
    void LostAndFound::addFoundItem(string itemName, string itemDesc) {
        Item item;
        item.name = itemName;
        item.desc = itemDesc;
        item.claimed = false;
        foundItems.push_back(item);
    }
    
    void LostAndFound::claimLostItem(string itemName) {
        for (int i = 0; i < lostItems.size(); i++) {
            if (lostItems[i].name == itemName && !lostItems[i].claimed) {
                lostItems[i].claimed = true;
                break;
            }
        }
    }
    
    void LostAndFound::listLostItems() {
        cout << "Lost Items: " << endl;
        for (int i = 0; i < lostItems.size(); i++) {
            if (!lostItems[i].claimed) {
                cout << lostItems[i].name << " - " << lostItems[i].desc << endl;
            }
        }
    }
    
    void LostAndFound::listFoundItems() {
        cout << "Found Items: " << endl;
        for (int i = 0; i < foundItems.size(); i++) {
            if (!foundItems[i].claimed) {
                cout << foundItems[i].name << " - " << foundItems[i].desc << endl;
            }
        }
    }
    

    2、设计主函数:

    int main() {
        LostAndFound laf;
        laf.addLostItem
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 2月13日
  • 已采纳回答 2月5日
  • 创建了问题 2月5日

悬赏问题

  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'