#include"Product.h"
#include"all.h"
//Product赋值
void Product::Setdata(int idl, char* namel, int pricel, int numberl)
{
id = idl;
strcpy_s(name, namel);
price = pricel;
number = numberl;
}
//商品入库
void Product::input()
{
cout << "编号:";
cin >> id;
ifstream infile("Goods.dat", ios::in | ios::binary); //判断商品是否已存在
if (!infile)
{
d_show();
exit;
}
while (infile)
{
int n;
infile.read((char*)& p, sizeof(p));
n = infile.gcount();
if (n == sizeof(p))
if (p.id == id) {
cout << "货物已存在,请核实后再输入!" << endl;
return;
}
}
infile.close();
cout << "商品名:";
cin >> Goodsname;
cout << "单价:";
cin >> price;
cout << "数量:";
cin >> number;
p.Setdata(id, Goodsname, price, number);
ofstream outfile("Goods.dat", ios::app | ios::binary);
if (!outfile) {
d_show();
exit;
}
outfile.write((char*)& p, sizeof(p));
outfile.close();
b_show();
}
//显示所有商品
void Product::all()
{
ifstream infile("Goods.dat", ios::in | ios::binary);
if (!infile) { //如果打开文件失败,则创建文件
ofstream outfile("Goods.dat", ios::binary);
outfile.close();
}
cout << "编号\t" << "名字\t" << "单价\t" << "数量\t" << endl;
while (infile)
{
int n;
infile.read((char*)& p, sizeof(p));
n = infile.gcount();//获取长度
if (n == sizeof(p))
p.Showl();
}
infile.close();
}
//普通结账
void Product::count()
{
int s = 0, S = 0, k;
cout << "结束输入按“0”" << endl;
do {
cout << "商品编号:";
cin >> i;
cout << "购买数量:";
cin >> j;
b_show();
ifstream infile("Goods.dat", ios::in | ios::binary);
if (!infile)
{
d_show();
exit;
}
while (infile)
{
int n;
infile.read((char*)& p, sizeof(p));
n = infile.gcount();
if (n == sizeof(p))
if (p.id == i)
{
p.Show(j);
b_show();
s = p.price * j; //导入单价和购买数量,进行结算
S = S + s;
break;
}
}
infile.close();
} while (i != 0);
cout << "金额:" << S << endl;
cout << "收款:";
cin >> k;
cout << "找零:" << k - S << endl;
if (S > 300)
{ //消费超过300,办理会员
cout << "消费已超过200,可办理会员,“y/n”" << endl;
char l;
cin >> l;
if (l = 'y')
v.addVIP();
}
b_show();
}
//会员结账
void Product::vip_count() {
int s = 0, S = 0, k;
cout << "结束输入按“0”" << endl;
do {
cout << "商品编号:";
cin >> i;
cout << "购买数量:";
cin >> j;
ifstream infile("Goods.dat", ios::in | ios::binary);
if (!infile) {
d_show();
exit;
}
while (infile) {
int n;
infile.read((char*)& p, sizeof(p));
n = infile.gcount();
if (n == sizeof(p))
if (p.id == i)
{
p.Show(j);
b_show();
s = p.price * j; //导入单价和购买数量,进行结算
S = S + s;
r.viprecord();
break;
}
}
infile.close();
} while (i != 0);
cout << "金额:" << S << endl;
cout << "会员价:" << S * 0.9 << endl;
cout << "收款:";
cin >> k;
cout << "找零:" << k - (S * 0.9) << endl;
b_show();
}
// 商品显示
void Product::Show(int j)
{
cout << "编号\t" << "名字\t" << "单价\t" << "余量\t" << endl << id << "\t" << name << "\t" << price << "\t" << number - j << endl;
}
没有合适的资源?快使用搜索试试~ 我知道了~
课程设计-C++商店收银系统(控制台).rar
共14个文件
h:5个
cpp:5个
filters:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 18 浏览量
2022-06-25
21:52:30
上传
评论
收藏 11KB RAR 举报
温馨提示
系统针对超市收银系统和商品管理系统,面对大量纷繁复杂的管理操作,对不同商品的增加和删除和更改信息,以及 消费者信息的维护,需要设计一个合理的系统,它应包括商品类,会员类,和基于会员类的VIP类和超市的收入信息,建立本超市收银系统的目的是实现无纸化超市收管理,减轻管理员的工作量,实现收银维护和信息上架的一体化管理,并要求对管理员进行身份验证。(VS可直接运行)。黑框控制台程序
资源推荐
资源详情
资源评论
收起资源包目录
课程设计-C++商店收银系统(控制台).rar (14个子文件)
C++商店收银系统
.vs
lab1
v14
.suo 22KB
lab1
show.h 793B
VIP.h 562B
lab1.vcxproj.filters 2KB
VIP.cpp 2KB
all.cpp 127B
record.cpp 1KB
all.h 219B
main.cpp 2KB
record.h 1KB
Product.cpp 3KB
lab1.vcxproj 7KB
Product.h 1006B
lab1.sln 1KB
共 14 条
- 1
资源评论
等天晴i
- 粉丝: 5077
- 资源: 10万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功