로그인
(1) 관리자 모드
- 책 추가 (Input : 책 제목, 출판사, 종류)
- 책 삭제 (Input : 책 제목)
- 사용자들의 대출 리스트 (Output : 사용자 이름, 전공, 학번, 대출날짜)
- 책 검색 (Input : 책 제목 / Output : 출판사, 종류, 코드, 대출여부)
- 전체 책 목록 (Output : 책 제목, 출판사, 종류, 코드, 대출여부)
(2) 사용자 모드
- 책 대출 (Input : 책 제목, 코드)
- 책 반납 (Input : 책 제목, 코드)
- 나의 대출 리스트 (Output : 책 제목, 코드, 대출날짜)
- 책 검색 (Input : 책 제목 / Output : 출판사, 종류, 코드, 대출여부)
- 전체 책 목록 (Output : 책 제목, 출판사, 종류, 코드, 대출여부)
사용자 추가
사용자 삭제
- 사용자 삭제 (Input : 이름)
//Rent.h
#pragma once
#include <string>
#include <time.h>
#include <iostream>
using namespace std;
struct Rent{
char BookKind;
int BookCode;
int Personid;
int startDay;
//int useDay;
};
//Person.h
#pragma once
#include <string>
#include <iostream>
#define pMax 10
using namespace std;
class Person
{
private:
int id;
string major;
string PersonName;
public:
Person(string PersonName = "아무개", int id = 0, string major = "noname");
int getId();
void setId(int id);
string getMajor();
void setMajor(string major);
string getPersonName();
void setPersonName(string PersonName);
};
//Person.cpp
#include "Person.h"
Person::Person(string PersonName, int id , string major ) : id(id), major(major), PersonName(PersonName) {};
int Person::getId()
{
return id;
}
void Person::setId(int id)
{
this->id = id;
}
string Person::getMajor()
{
return major;
}
void Person::setMajor(string major)
{
this->major = major;
}
string Person::getPersonName()
{
return PersonName;
}
void Person::setPersonName(string PersonName)
{
this->PersonName = PersonName;
}
//PersonManage.h
#pragma once
#include "Person.h"
#include "RentBookList.h"
class PersonManage
{
private:
Person *PersonArray[pMax];
public:
int PersonCnt;
PersonManage();
Person** getPersonArray();
PersonManage & operator=(const PersonManage &r);
Person* findPerson(int id);
bool addPerson(Person* ap);
bool deletePerson(string PersonName);
// friend int RentBookList::getPersonId(Person &rp);
};
//PersonManage.cpp
#include "PersonManage.h"
#include <iostream>
using namespace std;
PersonManage::PersonManage() : PersonCnt(0)
{
PersonArray[pMax] = { NULL, };
};
Person** PersonManage::getPersonArray()
{
return PersonArray;
}
PersonManage& PersonManage::operator=(const PersonManage &r)
{
if (this == &r)
return *this;
for (int i = 0; i < this->PersonCnt; i++)
{
delete this->getPersonArray()[i];
}
this->PersonCnt = r.PersonCnt;
return *this;
}
Person* PersonManage::findPerson(int id)
{
for (int i = 0; i < PersonCnt; i++)
{
if (PersonArray[i]->getId() == id)
return PersonArray[i];
}
return NULL;
}
bool PersonManage::addPerson(Person *ap) //등록 성공 - 1, 등록 실패 - 0 리턴
{
if (PersonCnt > pMax)
return false;
else
{
for (int i = 0; i < PersonCnt; i++)
{
if (PersonArray[i]->getId() == ap->getId())
{
cout << "해당 학번은 이미 존재합니다." << endl;
return false;
}
}
PersonArray[PersonCnt] = new Person(ap->getPersonName(),ap->getId(), ap->getMajor());
PersonCnt++;
return true;
}
}
bool PersonManage::deletePerson(string PersonName) // 삭제 성공 - true, 삭제 실패 - false 리턴
{
int i;
int j;
int index = -1;
char ch;
if (PersonCnt == 0)
return false;
for (i = 0; i < PersonCnt; i++)
if (PersonArray[i]->getPersonName() == PersonName)
index = i;
if (index != -1) {
i = index;
cout << "정말 삭제하시겠습니까?(Y/N) : ";
cin >> ch;
if (ch == 'y' || ch == 'Y') {
delete PersonArray[i];
for (j = i; j < PersonCnt - 1; j++) {
PersonArray[i] = PersonArray[i + 1];
}
PersonCnt--;
return true;
}
else
return false;
}
return false;
}
//Book.h
#pragma once
#include <string>
#include <iostream>
using namespace std;
class Book
{
private:
string BookName;
string CpyName;
public:
Book();
Book(string BookName, string CpyName);
string getBookName();
void setBookName(string BookName);
string getCpyName();
void setCpyName(string CpyName);
virtual void infoView() = 0;
virtual bool getflag() = 0;
virtual void setflag(bool num) = 0;
};
//Book.cpp
#include <string>
#include <iostream>
using namespace std;
#include "Book.h"
Book::Book() :BookName(""), CpyName("")
{}
Book::Book(string BookName, string CpyName) : BookName(BookName), CpyName(CpyName)
{}
string Book::getBookName()
{
return BookName;
}
void Book::setBookName(string BookName)
{
this->BookName = BookName;
}
string Book::getCpyName()
{
return CpyName;
}
void Book::setCpyName(string CpyName)
{
this->CpyName = CpyName;
}
//Novel.h
#pragma once
#include "Book.h"
class Novel : public Book {
char BookKind;
int BookCode;
bool flag = false;
public:
static int NovelNum;
Novel();
Novel(string BookName, string CpyName, char kind);
char getBookKind();
void setBookKind(char kind);
int getBookCode();
void setBookCode(int Code);
void infoView();
void setflag(bool num);
bool getflag();
};
//Novel.cpp
#include <string>
#include <iostream>
using namespace std;
#include "Novel.h"
int Novel::NovelNum = 1;
Novel::Novel() : Book("",""), BookKind(0)
{}
Novel::Novel(string BookName, string CpyName, char kind)
: Book(BookName, CpyName), BookKind(kind)
{
BookCode = NovelNum;
NovelNum++;
}
char Novel::getBookKind()
{
return BookKind;
}
void Novel::setBookKind(char kind)
{
BookKind = kind;
}
int Novel::getBookCode()
{
return BookCode;
}
void Novel::setBookCode(int Code)
{
BookCode = Code;
}
void Novel::infoView()
{
cout << "책제목 : " << this->getBookName() << " " << "출판사 : " << this->getCpyName() << " "
<< "책종류 : 소설 " << " " << "책코드 : " << this->BookKind << this->BookCode;
if (this->flag == true) cout << " (대출중...)";
cout << endl;
}
void Novel::setflag(bool num) {
this->flag = num;
}
bool Novel::getflag() {
return flag;
}
//Comic.h
#pragma once
#include "Book.h"
class Comic : public Book {
char BookKind;
int BookCode;
bool flag = false;
public:
static int ComicNum;
Comic();
Comic(string BookName, string CpyName, char kind);
char getBookKind();
void setBookKind(char kind);
int getBookCode();
void setBookCode(int Code);
void infoView();
void setflag(bool num);
bool getflag();
};
//Comic.cpp
#include <string>
#include <iostream>
using namespace std;
#include "Comic.h"
int Comic::ComicNum = 1;
Comic::Comic() : Book("", ""), BookKind(0)
{}
Comic::Comic(string BookName, string CpyName, char kind)
: Book(BookName, CpyName), BookKind(kind)
{
BookCode = ComicNum;
ComicNum++;
}
char Comic::getBookKind()
{
return BookKind;
}
void Comic::setBookKind(char kind)
{
BookKind = kind;
}
int Comic::getBookCode()
{
return BookCode;
}
void Comic::setBookCode(int Code)
{
BookCode = Code;
}
void Comic::infoView()
{
cout << "책제목 : " << this->getBookName() << " " << "출판사 : " << this->getCpyName() << " "
<< "책종류 : 만화 " << " " << "책코드 : " << this->BookKind << this->BookCode;
if (this->flag == true) cout << " (대출중...)";
cout << endl;
}
void Comic::setflag(bool num) {
this->flag = num;
}
bool Comic::getflag() {
return flag;
}
//MajorBook.h
#pragma once
#include "Book.h"
class MajorBook : public Book {
char BookKind;
int BookCode;
bool flag = false;
public:
static int MajorNum;
MajorBook();
MajorBook(string BookName, string CpyName, char kind);
char getBookKind();
void setBookKind(char kind);
int getBookCode();
void setBookCode(int Code);
void infoView();
void setflag(bool num);
bool getflag();
};
//MajorBook.cpp
#include <string>
#include <iostream>
using namespace std;
#include "MajorBook.h"
int MajorBook::MajorNum = 1;
MajorBook::MajorBook() : Book("", ""), BookKind(0)
{}
MajorBook::MajorBook(string BookName, string CpyName, char kind)
: Book(BookName, CpyName), BookKind(kind)
{
BookCode = MajorNum;
MajorNum++;
}
char MajorBook::getBookKind()
{
return BookKind;
}
void MajorBook::setBookKind(char kind)
{
BookKind = kind;
}
int MajorBook::getBookCode()
{
return BookCode;
}
void MajorBook::setBookCode(int Code)
{
BookCode = Code;
}
void MajorBook::infoView()
{
cout << "책제목 : " << this->getBookName() << " " << "출판사 : " << this->getCpyName() << " "
<< "책종류 : 전공서적 " << " " << "책코드 : " << this->BookKind << this->BookCode;
if (this->flag == true) cout << " (대출중...)";
cout << endl;
}
void MajorBook::setflag(bool num) {
this->flag = num;
}
bool MajorBook::getflag() {
return flag;
}
//BookManage.h
#pragma once
#include "Book.h"
#include "Novel.h"
#include "MajorBook.h"
#include "Comic.h"
#include <stdlib.h>
#include "RentBookList.h"
#include <string>
using namespace std;
#define bMax 10
class BookManage
{
private:
Book* BookArray[bMax];
RentBookList List;
public:
int BookCnt;
BookManage();
~BookManage();
BookManage (const BookManage &r);
Book** getBookArray();
BookManage & operator=(const BookManage &r);
RentBookList &getRentBookList();
void printBook();
bool addBook(Book * ap);
bool deleteBook(string BookName);
Book *findBook(char BookKind, int BookCode);
};
//BookManage.cpp
#include <iostream>
#include "BookManage.h"
BookManage::BookManage() {
for (int i = 0; i < bMax; i++) {
this->BookArray[i] = NULL;
}
BookCnt = 0;
}
BookManage::~BookManage() {
for (int i = 0; i < bMax; i++) {
delete[] this->BookArray[i];
}
}
BookManage::BookManage(const BookManage &r) {
int i;
this->BookCnt = r.BookCnt;
for (i = 0; i < this->BookCnt; i++) {
if (dynamic_cast<Novel *>(r.BookArray[i]) != NULL) {
this->BookArray[i] = new Novel(*(dynamic_cast<Novel *>(r.BookArray[i])));
}
else if (dynamic_cast<MajorBook *>(r.BookArray[i]) != NULL) {
this->BookArray[i] = new MajorBook(*(dynamic_cast<MajorBook *>(r.BookArray[i])));
}
else if (dynamic_cast<Comic *>(r.BookArray[i]) != NULL) {
this->BookArray[i] = new Comic(*(dynamic_cast<Comic *>(r.BookArray[i])));
}
}
}
Book** BookManage::getBookArray() {
return this->BookArray;
}
BookManage & BookManage::operator=(const BookManage &r) {
int i;
if (this == &r) {
return *this;
}
this->BookCnt = r.BookCnt;
for (i = 0; i < this->BookCnt; i++)
{
delete this->BookArray[i];
}
for (i = 0; i < this->BookCnt; i++) {
if (dynamic_cast<Novel *>(r.BookArray[i]) != NULL) {
this->BookArray[i] = new Novel(*(dynamic_cast<Novel *>(r.BookArray[i])));
}
else if (dynamic_cast<MajorBook *>(r.BookArray[i]) != NULL) {
this->BookArray[i] = new MajorBook(*(dynamic_cast<MajorBook *>(r.BookArray[i])));
}
else if (dynamic_cast<Comic *>(r.BookArray[i]) != NULL) {
this->BookArray[i] = new Comic(*(dynamic_cast<Comic *>(r.BookArray[i])));
}
}
return *this;
}
void BookManage::printBook() {
for (int i = 0; i < this->BookCnt; i++) {
this->BookArray[i]->infoView();
}
}
bool BookManage::addBook(Book * ap) {
if (this->BookCnt < bMax) {
this->BookArray[this->BookCnt] = ap;
this->BookCnt++;
return true;
}
return false;
}
bool BookManage::deleteBook(string BookName) {
int i, res;
char YorN;
res = -1;
for (int i = 0; i < this->BookCnt; i++) {
if (this->BookArray[i]->getBookName() == BookName) {
res = i;
}
}
if (res == -1) {
return false;
}
else {
cout << "** 정말로 삭제하겠습니까?(y/n) : ";
cin >> YorN;
if (YorN == 'y' || YorN == 'Y') {
delete this->BookArray[res];
for (i = res; i < this->BookCnt - 1; i++) {
this->BookArray[i] = this->BookArray[i + 1];
if (i == this->BookCnt - 2)
this->BookArray[BookCnt - 1] = NULL;
}
this->BookCnt--;
return true;
}
else
return false;
}
}
Book *BookManage::findBook(char BookKind, int BookCode) {
Novel *np;
Comic *cp;
MajorBook *mp;
//cout << BookCnt << endl;
for(int i=0;i<BookCnt;i++){
if (dynamic_cast<Novel *>(BookArray[i]) != NULL) {
np = dynamic_cast<Novel *>(BookArray[i]);
//cout << np->getBookKind() << np->getBookCode() << endl;
if ((np->getBookKind()== BookKind) &&(np->getBookCode() == BookCode)) {
return BookArray[i];
}
}
else if (dynamic_cast<MajorBook *>(BookArray[i]) != NULL) {
mp = dynamic_cast<MajorBook *>(BookArray[i]);
if ((mp->getBookKind() == BookKind) && (mp->getBookCode() == BookCode)) {
return BookArray[i];
}
}
else if (dynamic_cast<Comic *>(BookArray[i]) != NULL) {
cp = dynamic_cast<Comic *>(BookArray[i]);
if ((cp->getBookKind() == BookKind) && (cp->getBookCode() == BookCode)) {
return BookArray[i];
}
}
}
return NULL;
}
RentBookList &BookManage::getRentBookList() {
return this->List;
}
//RentBookList.h
#pragma once
#include "Rent.h"
#include "Person.h"
#define bMax 10
class RentBookList {
private:
Rent * RentArray[bMax] = { NULL, };
public:
RentBookList();
~RentBookList();
Rent ** getRentArray();
// int getPersonId(Person &rp);
};
//RentBookList.cpp
#include "BookManage.h"
#include "PersonManage.h"
#include "Rent.h"
#include "RentBookList.h"
RentBookList::RentBookList()
{}
RentBookList::~RentBookList()
{}
Rent ** RentBookList::getRentArray()
{
return RentArray;
}
//int RentBookList::getPersonId(Person &rp)
//{
// return Personid;
//}
//main.cpp
#include <iostream>
using namespace std;
#include <string>
#define MASTER 1111 // 관리자 아이디
#define bMax 10
#pragma warning (disable : 4996)
#include "BookManage.h"
#include "PersonManage.h"
#include "Book.h"
#include "Person.h"
#include "Novel.h"
#include "MajorBook.h"
#include "Comic.h"
#include "RentBookList.h"
#include <ctime>
void PersonLogin(PersonManage &Pm, BookManage &Bm); // 관리자, 사용자 로그인
void masterMenu(PersonManage &Pm, BookManage &Bm); // 관리자 메뉴
void addbook(BookManage &Bm); // 책 추가
void deletebook(BookManage &Bm); // 책 삭제
void rentlist(PersonManage &Pm, BookManage &Bm); // 대출자 명단
void normalMenu(Person *p, BookManage &Bm); // 사용자 메뉴
void rentbook(int id, BookManage &Bm); // 책 대출
void returnbook(int id, BookManage &Bm); // 책 반납
void myrentlist(int id, BookManage &Bm); // 나의 대출 목록
void findbook(BookManage &Bm); // 단일 책 검색
void allbook(BookManage &Bm); // 책 목록 전체 보기
void PersonRegist(PersonManage &Pm); // 사용자 추가
void PersonDelete(PersonManage &Pm); // 사용자 삭제
int menu(const char **menuList, int menuCnt);
void displayTitle(const char *title);
int controlMenuSelect(const char *message, int menuCnt);
int inputInteger(const char *message);
void myFlush();
int main() {
BookManage bmanage;
PersonManage pmanage;
const char *menuList[] = { "로그인 ", "사용자 등록 ", "사용자 삭제 ", "종료 " };
int menuCnt = sizeof(menuList) / sizeof(menuList[0]);
int menuNum;
displayTitle("도서 관리 시스템 시작");
while (true)
{
menuNum = menu(menuList, menuCnt);
if (menuNum == menuCnt) { break; }
switch (menuNum)
{
case 1: PersonLogin(pmanage, bmanage); break;
case 2: PersonRegist(pmanage); break;
case 3: PersonDelete(pmanage); break;
}
}
displayTitle("도서 관리 시스템 종료");
return 0;
}
int menu(const char **menuList, int menuCnt)
{
int i;
int menuNum = 0; /* 입력된 메뉴 번호 저장 변수*/
cout << endl << "==================================" << endl;
for (i = 0; i < menuCnt; i++)
{
cout << i + 1 << "." << menuList[i] << endl;
}
cout << "==================================" << endl;
while (menuNum<1 || menuNum>menuCnt) /* 범위 내의 번호가 입력될 때 까지 반복*/
{
menuNum = inputInteger("# 메뉴번호를 입력하세요 : ");
}
return menuNum;
}
void displayTitle(const char *title)
{
cout << endl << "------------------------------" << endl;
cout << " " << title << endl;
cout << "------------------------------" << endl;
}
void PersonLogin(PersonManage &Pm, BookManage &Bm) {
Person * p;
int id;
displayTitle("로그인");
id = inputInteger("* 사용자 학번 : ");
if (id == MASTER) {
cout << "로그인 되었습니다." << endl;
masterMenu(Pm, Bm);
}
else {
p = Pm.findPerson(id);
if (p == NULL) {
cout << "존재하지 않는 입력입니다." << endl;
return;
}
cout << "로그인 되었습니다." << endl;
normalMenu(p, Bm);
}
}
void masterMenu(PersonManage &Pm, BookManage &Bm) {
const char *menuList[] = { "책 추가 ", "책 삭제 ", "대출자 명단 ", "책 검색 ", "전체 목록 ", "종료 " };
int menuCnt = sizeof(menuList) / sizeof(menuList[0]);
int menuNum;
displayTitle("관리자 모드 실행");
while (true)
{
menuNum = menu(menuList, menuCnt);
if (menuNum == menuCnt) { break; }
switch (menuNum)
{
case 1: addbook(Bm); break;
case 2: deletebook(Bm); break;
case 3: rentlist(Pm, Bm); break;
case 4: findbook(Bm); break;
case 5: allbook(Bm); break;
}
}
displayTitle("관리자 모드 종료");
}
void addbook(BookManage &Bm) {
string BookName;
string CpyName;
int num;
Book *ap = NULL;
bool res;
displayTitle("책 등록");
cout << "* 책 제목 : ";
cin >> BookName;
cout << "* 책 출판사 : ";
cin >> CpyName;
num = controlMenuSelect("* 책의 종류(1. 소설 / 2. 전공서적 / 3. 만화) : ", 3);
switch (num) {
case 1: ap = new Novel(BookName, CpyName, 'N'); break;
case 2: ap = new MajorBook(BookName, CpyName, 'M'); break;
case 3: ap = new Comic(BookName, CpyName, 'C'); break;
}
res = Bm.addBook(ap);
if (res)
{
cout << BookName << " 등록을 완료하였습니다." << endl << endl;
}
else
{
cout << "등록을 실패하였습니다." << endl << endl;
}
}
void deletebook(BookManage &Bm) {
string BookName;
bool res;
displayTitle("책 삭제");
cout << "* 책 제목 : ";
cin >> BookName;
res = Bm.deleteBook(BookName);
if (res)
{
cout << BookName << "이 삭제되었습니다." << endl << endl;
}
else
{
cout << "삭제를 실패하였습니다." << endl << endl;
}
}
void rentlist(PersonManage &Pm, BookManage &Bm) {
displayTitle("대출자 명단");
Rent **list;
list = Bm.getRentBookList().getRentArray();
for (int i = 0;i< bMax;i++) {
if (list[i] != NULL) {
Person* a = Pm.findPerson(list[i]->Personid);
Book * b = Bm.findBook(list[i]->BookKind, list[i]->BookCode);
cout << "이름 : " << a->getPersonName() << ", 전공 : " << a->getMajor() << ", 학번 : " << a->getId() << " (" << b->getBookName() << " 대출날짜 : " << list[i]->startDay << "일)" << endl;
}
}
cout << endl;
}
void normalMenu(Person *p, BookManage &Bm) {
const char *menuList[] = { "대출 ", "반납 ", "대출명단 ", "책검색 ","전체 목록 ","종료 " };
int menuCnt = sizeof(menuList) / sizeof(menuList[0]);
int menuNum;
int id = p->getId();
displayTitle("사용자 메뉴");
while (true)
{
menuNum = menu(menuList, menuCnt);
if (menuNum == menuCnt) { break; }
switch (menuNum)
{
case 1: rentbook(id, Bm); break;
case 2: returnbook(id, Bm); break;
case 3: myrentlist(id, Bm); break;
case 4: findbook(Bm); break;
case 5: allbook(Bm); break;
}
}
displayTitle("사용자 메뉴 종료");
}
void rentbook(int id, BookManage &Bm) {
displayTitle("대출");
string bookname;
char ch;
int n;
Rent **list;
list = Bm.getRentBookList().getRentArray();
cout << "* 책 제목 : ";
cin >> bookname;
for (int i = 0; i < Bm.BookCnt;i++) {
if (Bm.getBookArray()[i]->getBookName() == bookname) {
cout << "* 책 코드 : ";
cin >> ch >> n;
Book * b = Bm.findBook(ch, n);
if (b != NULL) {
if (b->getBookName() != bookname) {
cout << "대출이 불가능합니다." << endl;
return;
}
for (int i = 0; i < Bm.BookCnt;i++) {
if (list[i] != NULL) {
//cout << list[i]->BookKind << list[i]->BookCode << endl;
if (list[i]->BookKind == ch && list[i]->BookCode == n) {
cout << "대출이 불가능합니다." << endl;
return;
}
}
}
}
else {
cout << "대출이 불가능합니다." << endl;
return;
}
// 도서관에도 책이 있고, 대출도서명단에 책이 없을때, 즉, 대출 가능
time_t day = time(NULL);
for (int i = 0;i < Bm.BookCnt;i++) {
if (list[i] == NULL) {
time_t timer;
struct tm *t;
timer = time(NULL); // 현재 시각을 초 단위로 얻기
t = localtime(&timer);
list[i] = new Rent;
list[i]->BookKind = ch;
list[i]->BookCode = n;
list[i]->Personid = id;
list[i]->startDay = t->tm_mday;
cout << "대출이 완료되었습니다." << endl;
b->setflag(true);
break;
}
}
return;
}
}
cout << "대출이 불가능합니다." << endl;
}
void returnbook(int id, BookManage &Bm) {
displayTitle("반납");
string bookname;
char ch;
int n;
int num = 0;
Rent **list;
list = Bm.getRentBookList().getRentArray();
cout << "* 책 제목 : ";
cin >> bookname;
for (int i = 0; i < Bm.BookCnt;i++) {
if (Bm.getBookArray()[i]->getBookName() == bookname) {
cout << "* 책 코드 : ";
cin >> ch >> n;
Book * b = Bm.findBook(ch, n);
if (b != NULL) {
if (b->getBookName() != bookname) {
cout << "반납이 불가능합니다." << endl;
return;
}
}
// rent 배열 한칸씩 앞으로 떙기는 작업
for (int i = 0; i < Bm.BookCnt;i++) {
if (list[i] != NULL) {
if (list[i]->Personid == id) {
if (list[i]->BookKind == ch && list[i]->BookCode == n) {
// memset(list[i], 0, sizeof(Rent));
delete list[i];
for (i; i < Bm.BookCnt - 1; i++)
{
list[i] = list[i + 1];
if (i == Bm.BookCnt - 2)
{
// memset(list[i], 0, sizeof(Rent));
// delete list[Bm.BookCnt - 1];
list[Bm.BookCnt - 1] = NULL;
}
}
cout << "반납이 완료되었습니다." << endl;
b->setflag(false);
return;
}
else {
cout << "반납이 불가능합니다." << endl;
return;
}
}
}
}
cout << "반납이 불가능합니다." << endl;
return;
}
}
}
void myrentlist(int id, BookManage &Bm) {
displayTitle("나의 대출 책 목록");
Book * b;
Rent **list;
list = Bm.getRentBookList().getRentArray();
for (int i = 0; i < Bm.BookCnt;i++) {
if (list[i] != NULL) {
//cout << list[i]->Personid << " " << id << endl;
if (list[i]->Personid == id) {
b = Bm.findBook(list[i]->BookKind, list[i]->BookCode);
cout << "제목 : " << b->getBookName() << ", 코드 : " << list[i]->BookKind << list[i]->BookCode << " (대출 날짜 : " << list[i]->startDay << "일)" << endl;
}
}
}
}
void findbook(BookManage &Bm) {
displayTitle("책 검색");
cout << "* 책제목을 입력하세요: ";
char sBookName[50];
cin >> sBookName;
for (int i = 0; i < Bm.BookCnt; i++) {
if (Bm.getBookArray()[i]->getBookName() == sBookName) {
Bm.getBookArray()[i]->infoView();
}
}
}
void allbook(BookManage &Bm) {
displayTitle("전체 목록");
for (int i = 0; i < Bm.BookCnt; i++) {
cout << i + 1 << ". ";
Bm.getBookArray()[i]->infoView();
}
}
int controlMenuSelect(const char *message, int menuCnt)
{
int menuNum;
while (true)
{
menuNum = inputInteger(message);
if (menuNum > 0 && menuNum <= menuCnt) { break; }
}
return menuNum;
}
void PersonRegist(PersonManage &Pm) {
string personName;
string major;
int id;
Person *ap = NULL;
bool res;
displayTitle("사용자 등록하기");
cout << "* 사용자 이름 : ";
cin >> personName;
cout << "* 사용자 전공 : ";
cin >> major;
id = inputInteger("* 사용자 학번 : ");
ap = new Person(personName, id, major);
res = Pm.addPerson(ap);
if (res)
{
cout << personName << "님의 등록을 완료하였습니다." << endl << endl;
}
else
{
cout << "등록을 실패하였습니다." << endl << endl;
}
}
void PersonDelete(PersonManage &Pm)
{
string personName;
bool res;
displayTitle("사용자 탈퇴하기");
cout << "* 사용자 이름 : ";
cin >> personName;
res = Pm.deletePerson(personName);
if (res)
{
cout << personName << "님의 정보가 삭제되었습니다." << endl << endl;
}
else
{
cout << "탈퇴를 실패하였습니다." << endl << endl;
}
}
int inputInteger(const char *message)
{
int number;
while (1) {
cout << message;
cin >> number;
if (cin.get() == '\n') {
return number;
}
myFlush();
}
}
void myFlush()
{
cin.clear();
while (cin.get() != '\n');
}