求一个自动贩卖机的C++源代码程序

求一个自动贩卖机的C++源代码程序,第1张

#include <iostream>

#include <string>

#include <vector>

#include <cstdlib>

using namespace std;

struct Drink{

Drink(float pr, string n);

string name;

float price;

int account;

};

class Vending{

public:

Vending();

inline void showStorage() const {

cout << "可乐:" << m_cola->account << endl << "奶茶:" << m_milkT->account << endl;

cout << "凉茶:" << m_T->account << endl;

}

inline void showSoldNum() const{

cout << m_cola->name << endl << "销售量:" << m_soldCola << endl;

cout << "销售额:" << m_soldCola(m_cola->price) << endl;

cout << m_milkT->name << endl << "销售量:" << m_soldMilkTea << endl;

cout << "销售额:" << m_soldMilkTea(m_milkT->price) << endl;

cout << m_T->name << endl << "销售量:" << m_soldTea << endl;

cout << "销售额:" << m_soldTea(m_T->price) << endl;

}

void addStore();

void sellItem();

void popMenu();

private:

Drink m_cola, m_milkT, m_T;

int m_soldCola, m_soldMilkTea, m_soldTea;

};

Drink::Drink(float pr, string n)

:name(n), price(pr), account(0){}

Vending::Vending()

:m_soldCola(0), m_soldMilkTea(0), m_soldTea(0)

{

m_cola = new Drink(float(28), "可乐");

m_milkT = new Drink(float(30), "奶茶");

m_T = new Drink(float(35), "凉茶");

}

void Vending::addStore(){

cout << "请选择要上架的商品:\n1可乐\n2奶茶\n3凉茶\n";

int n, count;

cin >> n;

if(n > 3){

cout << "选择错误" << endl;

return;

}

cout << "请输入要上架的数量:";

cin >> count;

if(n == 1)

m_cola->account += count;

else if(n == 2)

m_milkT->account += count;

else if(n == 3)

m_T->account += count;

else{

cout << " *** 作失败" << endl;

return;

}

cout << " *** 作完成" << endl;

}

void Vending::sellItem(){

cout << "1" << m_cola->name << ":" << endl;

cout << "价格:" << m_cola->price << ends << "库存:" << m_cola->account << (m_cola->account == 0 "(售完)\n" : "\n");

cout << "2" << m_milkT->name << ":" << endl;

cout << "价格:" << m_milkT->price << ends << "库存:" << m_milkT->account << (m_milkT->account == 0 "(售完)\n" : "\n");

cout << "3" << m_T->name << ":" << endl;

cout << "价格:" << m_T->price << ends << "库存:" << m_T->account << (m_T->account == 0 "(售完)\n" : "\n");

cout << "请选择:";

int n = 0, num = 0;

cin >> n;

float price = 0;

int acc = 0;

if(n == 1){

price = m_cola->price;

acc = m_cola->account;

}

else if(n == 2){

price = m_milkT->price;

acc = m_milkT->account;

}

else if(n == 3){

price = m_T->price;

acc = m_T->account;

}

do

{

if(num > 0)

cout << "库存不足" << endl;

cout << "请输入数量:";

cin >> num;

}while(num > acc);

price = num;

float pay = 0;

do

{

if(pay > 0)

cout << "支付不足" << endl;

cout << "请支付:";

cin >> pay;

}while (pay < price);

cout << " *** 作完成" << endl;

if(pay - price > 0)

cout << "找零:" << pay-price << endl;

if(n == 1){

m_soldCola += num;

m_cola->account -= num;

}

else if(n == 2){

m_soldMilkTea += num;

m_milkT->account -= num;

}

else if(n == 3){

m_soldTea += num;

m_T->account -= num;

}

}

void Vending::popMenu(){

const string menu1 = "========自动贩卖机========\n1管理人员界面\n2销售界面\n3退出\n";

const string menu2 = "========自动贩卖机========\n1显示库存\n2商品上架\n3销售查询\n";

int n;

while(true){

cout << menu1 << "请选择:";

cin >> n;

if(n == 1){

cout << "请输入密码:";

int password;

cin >> password;

if(password != 123){

cout << "密码错误" << endl;

continue;

}

cout << menu2 << "请选择:";

cin >> n;

switch(n){

case 1:{

showStorage();

break;

}

case 2:{

addStore();

break;

}

case 3:{

showSoldNum();

break;

}

default:{

cout << "选择错误" << endl;

return;

}

}

}

else if(n == 2)

sellItem();

else if(n == 3)

exit(0);

}

}

int main(){

Vending vend = new Vending;

vend->popMenu();

return 0;

}

1 打开京东APP或官网,登录账号;

2 进入“我的服务”-“回收服务”,选择您要回收的商品;

3 进入商品详情页,上传商品照片并确认回收价格;

4 选择收货地址,提交回收订单;

5 京东会尽快安排快递上门取件,送至京东回收中心;

6 经过初步检测后,京东会向您开具发票并支付回收金额;

7 如果发现商品有质量问题,京东会及时将相关检测报告发送至您的手机。

不会。根据查询公开信息显示,淘宝平台上的虚拟物品多数都是数字或者代码,发放后无法收回。如果出现了卖家欺诈行为,如虚假宣传、不提供商品等情况,可以向淘宝客服投诉,协商退款事宜。同时,在购买虚拟商品的时候,建议仔细看清商品描述、评价等信息,避免购买后后悔。

以上就是关于求一个自动贩卖机的C++源代码程序全部的内容,包括:求一个自动贩卖机的C++源代码程序、如何在京东回收商品、淘宝买的源码退货后源码会被收回吗等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10118123.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-05
下一篇 2023-05-05

发表评论

登录后才能评论

评论列表(0条)

保存