c++车辆管理系统的设计与实践

编写一个程序,用于客车和货车管理。其中,所有的车辆都有车牌号、颜色、出厂时间、车主等信息,客车另有载客量、运营路线等信息,货车另有载货量等信息。要求能够输入、显示上述信息,并且能够按照车牌号码进行检索。

https://wenku.baidu.com/view/8e629b7791c69ec3d5bbfd0a79563c1ec4dad700.html

这里有源码

可以用向日葵提供远程技术支持。

代码写了一些,参考吧。

#include <stdio.h>
#include <string>
#include <map>

using namespace std;
//定义时间类型
struct Datetime
{
	int year;
	int mon;
	int day;
	Datetime(){year = 2021; mon = 1;day = 1;}
};
//定义汽车类型
enum ECarType
{
	e_type_ke = 0,
	e_type_hc
};

//车类
class Car
{
public:
	char chepai[10];
	char color[8];
	Datetime time;
	char chezhu[20];
	ECarType type;
public:
	Car(){memset(chepai,0,10);memset(color,0,8);memset(chezhu,0,20);}
};
//客车类
class Keche : public Car
{
public:
	int zkl;         //载客量
	char luxian[20]; //运营路线,也可以单独定义一个路线类
public:
	Keche(){zkl = 0; memset(luxian,0,20);type = e_type_ke;}
};

//货车类
class Huoche :public Car
{
public:
	int zhl;    //载货量
public:
	Huoche(){zhl = 0;type = e_type_hc;}
};

int main()
{
	map<string,Car > mapAllcar;  //存储所有车辆信息
	
	printf("1.添加客车\n");
	printf("2.添加货车\n");
	printf("3.删除客车\n");
	printf("4.删除货车\n");
	printf("5.车辆查询\n");
	printf("6.显示全部车辆\n");
	printf("7.退出系统\n");
	
	while(true)
	{
		int n;
		char bufChepai[10] = {0};
		char bufColor[8] = {0};
		int y,m,d;
		int bufChezhu[20] = {0};
		int bufluxian[20] = {0};
		int zkl,zhl;
		Huoche hc;
		Keche kc;
		map<string,Car >::iterator it = mapAllcar.begin();  //存储所有车辆信息
		switch(n)
		{
		case 1:
			printf("请输入客车的车牌、颜色、出厂日期、车主、载客量、路线信息\n");
			scanf("%s %s %d %d %d %s %d %s",kc.chepai,kc.color,&kc.time.year,&kc.time.mon,&kc.time.day,kc.chezhu,&kc.zkl,kc.luxian);
			it = mapAllcar.find(kc.chepai);
			if (it == mapAllcar.end())
			{
				mapAllcar.insert(pair<string,Car >(kc.chepai,kc));
			}else
			{
				printf("已有该车牌的车辆\n");
			}
			break;
		case 2:
			break;
		case 3:
			break;
		case 4:
			break;
		case 5:
			break;
		case 6:
			break;
		case 7:
			break;
		}
	}
	return 0;
}

 

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632