c++ 车辆租赁信息管理系统 管理系统 实验设计 课程作业

#include <iostream>
#include <conio.h>
#include <fstream>
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <cstdlib>

using namespace std;

void customerData();
int carCount();
int custCount();
int rate(int, int);
void newCustData();
void carData ();
void admin();
void user();
void menu();
void fullscreen();
void art();
void exitArt();
void newCarData();
void delCar();
void displayCar();
void existingCust();
void load();
void load_CHECK();
void gotoxy(int , int );
void time();
void Boarder();
int countUser();
void tNc();
void readUserPass();
void availCar();
int countAvail();
const string currentDateTime();
const string Date();
void date();
void dispAvailCar();
void GotoXY(int , int );
void load_EXIT();
void load_UPDATE();
void newUserPass();
void password();
void resetAvail();
void showCarData();
void welcome();

struct car
{
    char plate_num[10];
    char brand[20];
    char model[20];
    float capacity;
    char colour[20];
    float rate_per_hour;
    float rate_per_half;
    float rate_per_day;
    char transmission[6];
};

struct customer
{
    int id;
    char name[100];
    char phone[15];
    char ic[15];
    char address[1500];
};

struct pass
{
    int ID;
    char passWord[20];
    
};

    pass userPass[1000];
    car rent[1000];
    customer cust[1000];
    car avail[1000];
    
void fullscreen()
{
    keybd_event(VK_MENU,0x38,0,0);
    keybd_event(VK_RETURN,0x1c,0,0);
    keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
    keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0);
}

const string currentDateTime() 
{
    time_t     now = time(0);
    struct tm  tstruct;
    char       buf[80];
    tstruct = *localtime(&now);
    strftime(buf, sizeof(buf), "%d/%m/%Y 时间: %X", &tstruct);

    return buf;
}

const string Date() 
{
    time_t     now = time(0);
    struct tm  tstruct;
    char       buf[80];
    tstruct = *localtime(&now);
    strftime(buf, sizeof(buf), "%d/%m/%Y 时间: %X", &tstruct);

    return buf;
}

void time()
{
    int i=0;
    
    while( i<5)
    {
    Boarder();
    gotoxy(20,20);
    std::cout <<"\n\n\n\n\n\t  |\t\t\t\t日期: "<<currentDateTime() << std::endl;
    Sleep(900);
    system("cls");
    i++;
    }
    menu();
}

void date()
{
    cout <<"\n\t  |\t\t\t\t\t\t日期: "<<Date()<<endl;

}

void readUserPass()
{
    ifstream ifs;
    ifs.open("UserPass.txt");
    
    int i;
    while(!ifs.eof())
    {
        ifs>>userPass[i].ID;
        ifs.ignore();
        ifs.getline(userPass[i].passWord,20);
        i++;
    }
    ifs.close();
}

void password()
{
    Boarder();
    
   countUser();
   string password;
   char c;
   gotoxy(40,20);
   cout << "\n\n\n\n\t  |\t\t\t密码: ";

    while(c != '\r') //循环直到按下回车键
         {
         c = getch();
         if(c == 0)
            {
            switch(getch())
               {
               default:
                  break;            
               };
            }
         else if(c == '\b')   //如果按下退格键
            {
            if(password.size() != 0)  //如果密码字符串包含数据,则擦除最后一个字符
               {
               cout << "\b \b";
               password.erase(password.size() - 1, 1);
               }
            continue;
            }
         else if(c <= '9' && c >= '0' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')  //如果用户输入1-9、 a-z 或 a-z,将其添加到密码中并显示星号
            {
            password += c;
            cout << "*";
            }
         else
            continue;
         }
         
         for(int i=0; i<countUser();i++)
         {
             if(password.compare(userPass[i].passWord)==0)
             {
                 system("cls");
                 load_CHECK();
                  admin();
             }
         }
         
         
          if(password == "a")
              {
          system("cls");
          load_CHECK();
          admin();
              }
              
          else
          cout<<"\n\t  |\t\t\t密码错误.. 呼叫管理员";
          cout<<"\n\t  |\t\t\t回到主菜单.."<<endl;
          cout<<"\n\t  |\t\t\t";
          Sleep(1000);
          cout<<"\n\t  |\t\t\t按回车键继续.";
          cout<<"\n\t  |\t\t\t";
          getch();
          menu();
         
    
    
}

void gotoxy(int x, int y)
{

 COORD coord;

 coord.X = x;

 coord.Y = y;

 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);

}

void load()
{
    Boarder();
    
    int timer =5+ rand()%20;
    int row,col,r,c,q;
    gotoxy(65,34);
    cout<<"启动 ...";
    gotoxy(60,36);
    for(r=1;r<=timer;r++)
    {
    for(q=0;q<=100000000;q++);//慢慢地显示这个角色
    printf("%c",177);
    }
    Sleep(100);
    system("cls");
}

void load_CHECK()
{
    Boarder();
    int timer = rand()%5+1;
    int row,col,r,c,q;
    gotoxy(65,34);
    printf("登录...");
    gotoxy(60,36);
    for(r=1;r<=timer;r++)
    {
    for(q=0;q<=100000000;q++);//慢慢地显示这个角色
    printf("%c",177);
    }
    Sleep(100);
    system("cls");
}

void load_UPDATE()
{
    Boarder();
    
    int row,col,r,c,q;
    int timer = rand()%25+1;
    gotoxy(65,34);
    printf("更新数据库...");
    gotoxy(60,36);
    for(r=1;r<=timer;r++)
    {
    for(q=0;q<=100000000;q++);//慢慢地显示这个角色
    printf("%c",177);
    }
    Sleep(100);
    system("cls");
}

void load_EXIT()
{
    Boarder();
    
    int row,col,r,c,q;
    int timer = rand()%5+1;
    gotoxy(65,34);
    printf("下线...");
    gotoxy(60,36);
    for(r=1;r<=timer;r++)
    {
    for(q=0;q<=100000000;q++);//慢慢的显示这个角色 
    printf("%c",177);
    }
    Sleep(100);
    system("cls");
}

void GotoXY(int x, int y)
{
    HANDLE a;
    COORD b;
    fflush(stdout);
    b.X = x;
    b.Y = y;
    a = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(a,b);
 }

void Boarder()
{
in

一个简单的汽车租赁管理系统C++控制台程序): 利用C++实现对汽车和客户信息的增、删、改等操作,并保存。 部分代码: // CarRent.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "CarData.h" #include "Menu.h" #include"CustomerData.h" int main() { Menu::welcome(); Menu::login(); //登录界面 char choice; int carid, customerid; //汽车编号,客户编号 CustomerData CustomerDB; //客户库 Customer *r; //客户 CarData CarDB; //汽车库 Car *b; //汽车 Menu::showMenu(); //显示菜单 cout <> choice; while (choice != '0') { switch (choice) { case '1': //输入客户编号和要出租的汽车 cout <> customerid; try { if (customerid <= 0) throw 1; } catch (...) { cout << "输入有误,请重新输入"; break; } cout <> carid; try { if (carid <= 0) throw 1; } catch (...) { cout << "输入有误,请重新输入"; break; } r = CustomerDB.search(customerid); if (NULL == r) { cout << "不存在该客户!"; cout << endl; break; } b = CarDB.search(carid); if (b == NULL) { cout << "不存在该汽车!"; cout <borrowCar() == 0) { cout << "该汽车已租出!"; cout <borrowCar(b->getNo()); cout << "你在" <getBorTime()) << "成功出租一辆" <getName() << endl << "每日租金为(不足一天按一天计算):" <getPay(); break; case '2': //归还操作 cout <> customerid; try { if (customerid <= 0) throw 1; } catch (...) { cout << "输入有误,请重新输入"; break; } cout <> carid; try { if (carid <= 0) throw 1; } catch (...) { cout << "输入有误,请重新输入"; break; } r = CustomerDB.search(customerid); //按编号查找 if (r == NULL) { cout << "不存在该客户!" << endl; break; } b = CarDB.search(carid); if (b == NULL) { cout << "不存在该汽车!" <getOnshelf() == 1) { cout << "该汽车已经归还!" << endl; break; } cout << "您成功归还一辆"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值