交通违章管理系统的设计与实现

本文展示了一个C++程序,涉及用户信息结构、违章记录处理、个人信息查询以及交通违章管理系统的实现,包括违章添加、查询和显示功能,以及用户反馈的收集和保存。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include <iostream>
#include <string>
#include <vector>
#include <map>  
#include <fstream>

using namespace std;
// 定义用户信息结构体

struct UserInfo 
{
    std::string name;
    std::string licensePlate;
    std::vector< std::string > violations;
};

// 显示用户信息函数
void displayUserInfo(const UserInfo& user)
 {
    std::cout << "姓名:" << user.name << std::endl;
    std::cout << "车牌号:" << user.licensePlate << std::endl;
    
    std::cout << "违章记录:" << std::endl;
    for (const std::string& violation : user.violations) {
        std::cout << "- " << violation << std::endl;
    }
}

// 查询用户信息函数
UserInfo queryUserInfo(const std::string& name) 
{
    UserInfo user;
    user.name = "张三";
    
    user.licensePlate = "京 A12345";
    user.violations = { "超速", "闯红灯", "违规停车" };

    return user;
}

struct PersonalInfo
{
    std::string name;
    std::string licensePlate;
    std::string year;
    int violationCount;
    std::vector< std::string > violations;
};

// 查询个人信息函数
void queryPersonalInfo() 
{
    PersonalInfo info;
    info.name = "张三";
    
    info.year="20";
    info.licensePlate = "京 A12345";
    info.violationCount = 3;

    std::cout << "姓名:" << info.name << std::endl;
    std::cout << "年龄:" <<info .year << std::endl;
    std::cout << "车牌号:" << info.licensePlate << std::endl;
    std::cout << "违章次数:" << info.violationCount << std::endl;
    cout<<"超速"<<endl;
    cout<<"闯红灯"<<endl;
    cout<<"违规停车"<<endl;            
}
// 违章信息类
class TrafficViolation 
{
public:
    std::string vehicleLicense;  // 车辆牌照
    std::string violationType;   // 违章类型
    std::string violationTime;   // 违章时间
};

// 交通违章管理系统类
class TrafficViolationManagementSystem 
{
private:
    std::map<std::string, TrafficViolation> violations;  // 保存违章信息的映射

public:
    // 添加违章信息
    void addViolation(const std::string& license, const std::string& typ

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值