书店管理系统

设计一个书店管理系统,能完成书店的日常管理工作。

要求完成的基本功能:

1、进货入库记录。

2、销售出货记录。

3、图书信息查询:可通过书名、作者等途径查询某本图书的详细信息(含书名、作者、出版社、页数、最新入库时间、库存量、价格等)。

4、自动预警提示(当某图书的库存量为1时自动预警提示)

模块化

根据类的继承与多态,我们可以创建以书Book为基类,BookStore为派生类,分为头文件.h和函数文件.c再加上主函数main.c即可

 类的分别实现

类的实现是在分别的.h文件当中,并且.h文件当中应当包含类所含成员函数和属性等等。

Book.h

#pragma once
#include <iostream>
#include <fstream>
#include <cstring>
#include <ctime>
#include <cstdlib>
using namespace std;

class Book {
private:
    string title, author, publisher, time;
    int pages, quantity;
    float price;

public:
    Book();

    void setTitle(string title);
    void setAuthor(string author);
    void setPublisher(string publisher);
    void setTime(string time);
    void setPages(int pages);
    void setQuantity(int quantity);
    void setPrice(float price);
    string getTitle();
    string getAuthor();
    string getPublisher();
    string getTime();
    int getPages();
    int getQuantity();
    float getPrice();
};

BookStore.h

#pragma once
#include <iostream>
#include <fstream>
#include <cstring>
#include <ctime>
#include <cstdlib>
using namespace std;

class BookStore
{
private:
    Book books[1000];
    int count;

public:
    BookStore();
    void addBook();
    void sellBook();
    void queryBook();
    void checkStock();
};

在.c文件中类外定义

注意带上头文件

Book.c

#include <iostream>
#include <fstream>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include "Book.h"
using namespace std;

Book::Book()
{
    // 初始化
    title = "";
    author = "";
    publisher = "";
    time = "";
    pages = 0;
    quantity = 0;
    price = 0.0;
}
//设置图书信息
void Book::setTitle(string title)
{
    this->title = title;
}
void Book::setAuthor(string author)
{
    this->author = author;
}
void Book::setPublisher(string publisher)
{
    this->publisher = publisher;
}
void Book::setTime(string time)
{
    this->time = time;
}
void Book::setPages(int pages)
{
    this->pages = pages;
}
void Book::setQuantity(int quantity)
{
    this->quantity = quantity;
}
void Book::setPrice(float price)
{
    this->price = price;
}
//获取图书信息
string Book::getTitle()
{
    return title;
}
string Book::getAuthor()
{
    return author;
}
string Book::getPublisher()
{
    return publisher;
}
string Book::getTime()
{
    return time;
}
int Book::getPages()
{
    return pages;
}
int Book::getQuantity()
{
    return quantity;
}
float Book::getPrice()
{
    return price;
}

主函数进行运行和设置菜单操作等,其余的请关注用户CodeSeven

我都放在那里面了,感谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值