历经两个周末,终于把这个Agenda-2020系统搞出来了,发篇博文庆祝一下~~
先展示一下成果吧~
学了一学期的C++到底能做什么呢?快来看看这个Agenda-2020系统吧~
如果你看完视频意犹未竟,那就来看看这系统是怎么实现的吧~
UI类(关于用户交互的类)
AgendaUI.hpp
#pragma once
#ifndef AGENDAUI_H
#define AGENDAUI_H
#include "AgendaService.h"
#include <iostream>
#include <string>
class AgendaUI {
public:
AgendaUI();
void OperationLoop(void);
private:
/**
* constructor
*/
void startAgenda(void);
/**
* catch user's operation
* @return the operation
*/
std::string getOperation();
/**
* execute the operation
* @return if the operationloop continue
*/
bool executeOperation(std::string t_operation);
/**
* user Login
*/
void userLogIn(void);
/**
* user regist
*/
void userRegister(void);
/**
* user logout
*/
void userLogOut(void);
/**
* quit the Agenda
*/
void quitAgenda(void);
/**
* delete a user from storage
*/
void deleteUser(void);
/**
* list all users from storage
*/
void listAllUsers(void);
/**
* user create a meeting with someone else
*/
void createMeeting(void);
/**
* list all meetings from storage
*/
void listAllMeetings(void);
/**
* list all meetings that this user sponsored
*/
void listAllSponsorMeetings(void);
/**
* list all meetings that this user take part in
*/
void listAllParticipateMeetings(void);
/**
* search meetings by title from storage
*/
void queryMeetingByTitle(void);
/**
* search meetings by timeinterval from storage
*/
void queryMeetingByTimeInterval(void);
/**
* delete meetings by title from storage
*/
void deleteMeetingByTitle(void);
/**
* delete all meetings that this user sponsored
*/
void deleteAllMeetings(void);
/**
* show the meetings in the screen
*/
void printMeetings(std::list<Meeting> t_meetings);
// dates
std::string m_userName;
std::string m_userPassword;
AgendaService m_agendaService;
};
#endif
AgendaUI.cpp
#include "AgendaUI.h"
#include "User.h"
#include "Meeting.h"
#include <iostream>
#include <iomanip>
using namespace std;
AgendaUI::AgendaUI()
{
m_userName = "UNDEFINED";
startAgenda();
}
void operateMessage(void)
{
cout << "\n---------------------------------------------------Agenda----------------------------------------------------" << endl;
cout << "Action :\n"
"o - log out Agenda\n"
"dc - delete Agenda account\n"
"lu - list all Agenda user\n"
"cm - create a meeting\n"
"amp - add meeting participator\n"
"rmp - remove meeting participator\n"
"rqm - request to quit meeting\n"
"la - list all meeting\n"
"las - list all sponsor meetings\n"
"lap - list all sponsor meetings\n"
"qm - query meeting by title\n"
"qt - query meeting by time interval\n"
"dm - delete meeting by title\n"
"da - delete all meetings"
<< endl;
cout << "----------------------------------------------------------------------------------------------------------------\n"
<< endl;
}
void operateMessage2(void)
{
cout << "---------------------------------------------------Agenda-------------------------------------------------------" << endl;
cout << "Action :\n"
"l - log in Agenda by user name and password\n"
"r - register an Agenda account\n"
"q - quit Agenda"
<< endl;
cout << "----------------------------------------------------------------------------------------------------------------" << endl;
cout << "Agenda :~$ ";
}
void AgendaUI::OperationLoop(void)
{
string opera ;
while ((opera = getOperation()) != "q")
{
executeOperation(opera);
operateMessage2(