关于电车充电系统的代码 物联网zty

本文描述了一个电车充电系统的类结构,包括用户管理(验证密码、查看余额、扣除余额)、充电桩状态检查、充电操作(选择充电方式、费用计算)以及充电记录的存储和查询。主要涉及类如user、ChargingStation和ChargingSystem,展示了用户登录、服务选择及系统功能的交互过程。
摘要由CSDN通过智能技术生成

#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<cstring>
#include <iomanip>
#include <vector>
using namespace std;
 
class user //检查密码,查看价格,查看使用后价格(getafterbalance)
{
private:
   string username;
   string password;
   string inpassword;
   double balance;
   int cishu=0;
public:
   user(string name, string pwd,string ipwd, double ibalance,int ci) :username(name), password(pwd), inpassword(ipwd),balance(ibalance),cishu(ci)
   {
 
   };
   string getusername()
   {
       return username;
   }
   void checkpassword(string pwd,string ipwd)
   {
       if (pwd == ipwd)
       {
           cout<<"用户通过检测";
       }
       else
       {
           cout<< "密码错误,请退出重试";
       }
   }
   //checkpassword(password,inpassword);
   void getbalance() //账户目前余额
   {
       cout<<"账户余额为:"<<balance<<endl;
   }
   void deductBalance(double amount) //账户剩余钱数
   {
       balance =balance - amount;
       cout << "进行一次充电后的余额为:" << balance << endl;
   }
 
   double getafterbalance(double amount)
   {
       balance=balance-amount;
       return balance;
       cishu++;
   }
   friend class ChargingStation;
   friend class ChargingRecord;
   friend class ChargingSystem;
};
 
class ChargingStation //是否可用,开始充电,停止充电
{
private:
   bool isOccupied = false;
   double csleftoil;
   double caroil;
   string chargetime;
   double icaro;
public:
   ChargingStation()
   {
 
   };
   ChargingStation(double oil,double caro) : isOccupied(false), csleftoil(oil),caroil(caro),icaro(caro)
   {
       //icaro = caro;
   };
   int situation = 0;//占用情况,0可用1不可
   int situa()
   {
       return situation;
   }
   void isAvailable()
   {
       if (isOccupied == true)
       {
           cout<< "充电桩暂时不可以使用"<<endl;
       }
       else
       {
           cout<< "充电桩可用,请将电车连接在桩上并开始充电"<<endl;
           isOccupied = false;
       }
   };
   void startCharging()
   {
       if (isOccupied = true && csleftoil != 0)
       {
           cout << "充电站可用,请连接并开始充电"<<endl;
           cout << "连接好后输入1开始充电" << endl;
           int a;
           cin >> a;
           if (a == 1)
           {
               cout << "充电开始"<<endl;
           }
       }
       else
       {
           cout << "充电站不可用"<<endl;
       }
     
   }
   void stopCharging()
   {
       while (caroil)
       {
           if (caroil >= 2000)
           {
               isOccupied = false;
               cout << "充电已经完成" << endl;
               break;
           }
           else
           {
               cout << "请稍侯,充电中"

  • 23
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值