-----<useclass.h>------
<cpp.cpp>-------
<cpp2.cpp>--------
~cpp
class book {
private :
// 보
public :
book *next;
book *first;
int situation,selection;
book();
~book();
char book_name[30];
char book_writer[15];
char book_ISBN[10];
void input();
void search();
void borrow();
void restoration();
};
------~cpp
#include <iostream>
#include "useclass.h"
using namespace std;
void main()
{
int number = 0;
book b;
while(number != 5)
{
cout << "1. 력 2.검 3.대 4.반납 5.료 : ";
cin >> number;
if(number == 5)
break;
switch(number)
{
case 1 :
b.input();
break;
case 2:
b.search();
break;
case 3:
b.borrow();
break;
case 4:
b.restoration();
break;
default :
cout<<"못 력다."<<endl;
break;
}
}
}
------~cpp
#include <iostream>
#include <string.h>
#include "useclass.h"
using namespace std;
book :: book(){
situation=0;
}
book :: ~book(){
}
void book :: input()
{
book * k = new book;
cout << " 목 : ";
cin >> k->book_name;
cout << " : ";
cin >> k->book_writer;
cout << " ISBN : ";
cin >> k->book_ISBN;
k->next=first;
first=k;
}
void book :: search(){
char name[30];
char ISBN[10];
cout<<" 과 ISBN . 1. 2.ISBN : ";
cin >> selection;
if (selection == 1){
cout<<" ?"<<endl;
cin>>name;
book *find;
find = first;
while(find->next !=NULL ){
if(strcmp(find->book_name,name)==0)
{
cout<<" 목 : "<<find->book_name<<endl;
cout<<" : "<<find->book_writer<<endl;
cout<<"ISBN : "<<find->book_ISBN<<endl;
if(find->situation==0){
cout<<" : 반납됨"<<endl;
}
else{
cout<<" : 대됨"<<endl;
}
break;
}
else{
if (find->next == NULL){
cout<<" 다."<<endl;
break;
}
else{
find=find->next;
}
}
}
}
else if (selection==2){
cout<<" ISBN?"<<endl;
cin>>ISBN;
book *find;
find = first;
while(find->next !=NULL ){
if(strcmp(find->book_ISBN,ISBN)==0){
cout<<" 목 : "<<find->book_name<<endl;
cout<<" : "<<find->book_writer<<endl;
cout<<"ISBN : "<<find->book_ISBN<<endl;
if(find->situation==0){
cout<<" : 반납됨"<<endl;
}
else{
cout<<" : 대됨"<<endl;
}
break;
}
else{
if (find->next == NULL){
cout<<" 다."<<endl;
break;
}
else{
find=find->next;
}
}
}
}
else{
cout<<"못 력다."<<endl;
}
}
void book :: borrow()
{
char name_temp[30];
char ISBN_temp[10];
cout << "빌릴 목 ISBN .: ";
cin >>selection;
if (selection == 1){
cout<<"빌릴 목 : ";
cin >> name_temp;
book *lent;
lent = first;
while(lent->next !=NULL ){
if(strcmp(lent->book_name,name_temp)==0){
lent->situation = 1;
break;
}
else{
lent=lent->next;
}
}
}
else if (selection==2){
cout<<"빌릴 ISBN : ";
cin >> ISBN_temp;
book *lent;
lent = first;
while(lent->next !=NULL ){
if(strcmp(lent->book_ISBN,ISBN_temp)==0){
lent->situation = 1;
break;
}
else{
lent=lent->next;
}
}
}
else{
cout<<"못 력다."<<endl;
}
}
void book :: restoration()
{
char restoration_name[30];
char restoration_ISBN[10];
cout<<"반납 ISBN 력. 1. 2.ISBN: ";
cin >> selection;
if ( selection == 1){
cout << "반납 된 : ";
cin >> restoration_name;
book *restore;
restore = first;
while(restore->next !=NULL ){
if(strcmp(restore->book_name,restoration_name)==0)
{
restore->situation = 0;
break;
}
else{
restore=restore->next;
}
}
}
else if (selection ==2){
cout << "반납 된 ISBN : ";
cin >> restoration_ISBN;
book *restore;
restore = first;
while(restore->next !=NULL ){
if(strcmp(restore->book_ISBN,restoration_ISBN)==0)
{
restore->situation = 0;
break;
}
else{
restore=restore->next;
}
}
}
else{
cout<<"못 력다."<<endl;
}
}










