C++面向对象课程设计——4S店管理系统(源代码内附流程图)

这是一个使用C++编写的4S店管理系统,包括了商品类、零配件类、车辆类和服务类的定义及功能实现。系统实现了商品查找、销售、售后服务记账等功能,并提供了销售情况、库存状态的查询。源代码包含详细注释,便于理解面向对象编程的应用。
摘要由CSDN通过智能技术生成

#include<iostream>
#include<fstream>
#include<map>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
class Goods{ //商品类
    protected:
      string Id;
      string Name;
      string Brand;
      double BuyingPrice;
      double RetailPrice;
      int Stock;
      int Sales;
    public:
      Goods(string id,string n,string b,double bp,double rp,int st=0,int sa=0);
      void setBPrice(double bp);
      void setRPrice(double rp);
      string getId();
      string getName();
      double getBPrice();
      double getRPrice();
      int getStock();
      int getSales();
      void setStock(int s);
      void setSales(int s);
      virtual void showInfo()=0;
};
Goods::Goods(string id,string n,string b,double bp,double rp,int st,int sa)
:Id(id),Name(n),Brand(b),BuyingPrice(bp),RetailPrice(rp),Stock(st),Sales(sa){}
void Goods::setBPrice(double bp){
  BuyingPrice=bp;
}
void Goods::setRPrice(double rp){
  RetailPrice=rp;
}
string Goods::getId(){
  return Id;
}
string Goods::getName(){
  return Name;
}
double Goods::getBPrice(){
  return BuyingPrice;
}
double Goods::getRPrice(){
  return RetailPrice;
}
int Goods::getStock(){
  return Stock;
}
int Goods::getSales(){
  return Sales;
}
void Goods::setStock(int s){
  Stock=s;
}
void Goods::setSales(int s){
  Sales=s;
}

class Sparepart:public Goods{ //零配件类
    protected:
      string Source; //来源 (原厂配件、第三方配件)
      char Quality;  //品质 (A、B、C三级)
      int Guarantee; //保修期 (年)
    public:
      Sparepart(string id,string n,string b,double bp,double rp,int st,int sa,string sou,char qua,int gua);
      virtual void showInfo(); //虚函数
      friend ostream& operator<<(ostream& os,Sparepart &s);
};
Sparepart::Sparepart(string id,string n,string b,double bp,double rp,int st,int sa,string sou,char qua,int gua)
:Goods(id,n,b,bp,rp,st,sa),Source(sou),Quality(qua),Guarantee(gua){}
void Sparepart::showInfo(){
  cout<<"编号:"<<Id<<"\t";
  cout<<"名称:"<<Name<<"\t";
  cout<<"品牌:"<<Brand<<endl;
  cout<<"进价:¥"<<BuyingPrice<<"\t";
  cout<<"售价:¥"<<RetailPrice<<endl;
  cout<<"库存:"<<Stock<<"\t";
  cout<<"销量:"<<Sales<<endl;
  cout<<"来源:"<<Source<<"\t";
  cout<<"品质:"<<Quality<<"\t\t";
  cout<<"保修:"<<Guarantee<<" 年"<<endl;
}
ostream& operator<<(ostream& os,Sparepart &s){
  os<<s.Id<<" "<<s.Name<<" "<<s.Brand<<" "<<s.BuyingPrice<<" "<<s.RetailPrice<<" "
  <<s.Stock<<" "<<s.Sales<<" "<<s.Source<<" "<<s.Quality<<" "<<s.Guarantee<<endl;
  return os;
}


class Car:public Goods{ //车类
    protected:
      string Energy; //能源类型 (汽油,电动,天然气,太阳能)
      double Speed; //最高时速 km/h
      char Safety; //安全性 (A、B、C三级)
    public:
      Car(string id,string n,string b,double bp,double rp,int st,int sa,string e,double sp,char safe);
      virtual void showInfo();
      friend ostream& operator<<(ostream& os,Car &c);
};
Car::Car(string id,string n,string b,double bp,double rp,int st,int sa,string e,double sp,char safe)
:Goods(id,n,b,bp,rp,st,sa),Energy(e),Speed(sp),Safety(safe){}

void Car::showInfo(){
  cout<<"编号:"<<Id<<"\t\t";
  cout<<"名称:"<<Name<<endl;
  cout<<"品牌:"<<Brand<<endl;
  cout<<"进价:¥"<<BuyingPrice<<"\t\t";
  cout<<"售价:¥"<<RetailPrice<<endl;
  cout<<"库存:"<<Stock<<"\t\t";
  cout<<"销量:"<<Sales<<endl;
  cout<<"能源类型:"<<Energy<<"\t";
  cout<<"最高时速:"<<Speed<<" km/h"<<endl;
  cout<<"安全性:"<<Safety<<endl;
}
ostream& operator<<(ostream& os,Car

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值