Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

help help help help help C++C+C+C++ part 2

windwind Member Posts: 11
#include "dlist.h"
#include
#include


void print_menu();
void add_video();
void displayX(CDList displaydat);
void listallvid();
void searchVid();
void displayVidDetail();
void add_subscriber();
void displaySub(CDList displaydat);
void displaySubDetail();
void add_rental();
void returnVid();
void DisplayRentedVid();

int vcounter = 0;
int scounter = 0;
int rcounter = 0;
CDList Video[100];
CDList Rental[100];
CDList Subscriber[100];
CDList::iterator iter;

int main()
{


try
{
bool bExit = 0;
int sel = 0;
while(!bExit)
{
print_menu();
std::cin >> sel;
switch(sel)
{
case 1:
add_video();
break;
case 2:
listallvid();
break;
case 3:
searchVid();
break;
case 4:
displayVidDetail();
break;
case 5:
add_subscriber();
break;
case 6:
displaySubDetail();
break;
case 7:
add_rental();
break;
case 8:
returnVid();
break;
case 9:
DisplayRentedVid();
break;
case 0:
bExit = 1;
break;
default:
std::cout << "unknown selection" << std::endl;
}
system("pause");
system("cls");
std::cin.sync();
}
}
catch(char *str) {
std::cerr << "Exception: " << str << std::endl;
}
catch(...) {
std::cerr << "The program has stoped due to some unknown exception" << std::endl;
}
return 0;
}

void add_video()
{
CDList<std::string> VideoList;

std::string element;

std::cout << "Please enter Video Title
";
std::cin >> element;
std::cin.sync();
VideoList.push_back(element);
std::cout << "Please enter main Actor/Actress
";
std::cin >> element;
std::cin.sync();
VideoList.push_back(element);
std::cout << "Please enter main Actor/Actress
";
std::cin >> element;
std::cin.sync();
VideoList.push_back(element);
std::cout << "Please enter movie producer
";
std::cin >> element;
std::cin.sync();
VideoList.push_back(element);
std::cout << "Please enter movie director
";
std::cin >> element;
std::cin.sync();
VideoList.push_back(element);
std::cout << "Please enter movie production company
";
std::cin >> element;
std::cin.sync();
VideoList.push_back(element);
std::cout << "Please enter copies in stock
";
std::cin >> element;
std::cin.sync();
VideoList.push_back(element);

vcounter++;
Video[vcounter] = VideoList;

}

void add_subscriber()
{
CDList subList;

std::string element;

std::cout << "Please enter Name
";
std::cin >> element;
std::cin.sync();
subList.push_back(element);
std::cout << "Please enter IC number/Actress
";
std::cin >> element;
std::cin.sync();
subList.push_back(element);
std::cout << "Please enter address/Actress
";
std::cin >> element;
std::cin.sync();
subList.push_back(element);
std::cout << "Please enter Deposit
";
std::cin >> element;
std::cin.sync();
subList.push_back(element);

scounter++;
Subscriber[scounter] = subList;
}

void add_rental()
{
CDList rentList;
std::string element;
std::string temp;

std::cout << "Please enter Rental NO: ";
std::cin >> element;
std::cin.sync();
rentList.push_back(element);
temp = element;

std::cout << "Please enter Renter Name
";
std::cin >> element;
std::cin.sync();
rentList.push_back(element);

std::cout << "Please enter Video Title
";
std::cin >> element;
std::cin.sync();
rentList.push_back(element);
std::cout << "Please enter Date Rented
";
std::cin >> element;
std::cin.sync();
rentList.push_back(element);


rcounter++;
Rental[rcounter] = rentList;

std::cout << "Rental is : " + temp << std::endl;
}



void print_menu()
{
std::cout << "
Video Rental System" << std::endl;
std::cout << "================================================" << std::endl;
std::cout << "[1.] to Add an video" << std::endl;
std::cout << "[2.] to List all video in store" << std::endl;
std::cout << "[3.] to Search for a video" << std::endl;
std::cout << "[4.] to Diplay a Video detail" << std::endl;
std::cout << "[5.] to Add a new Subscriber" << std::endl;
std::cout << "[6.] to Diplay a Subscriber detail" << std::endl;
std::cout << "[7.] to Rent out a video" << std::endl;
std::cout << "[8.] to Return back a video" << std::endl;
std::cout << "[9.] to Display all video rented by a customer" << std::endl;
std::cout << "[0.] to Exit" << std::endl;
std::cout << "
selection: ";
}



void displayX(CDList<std::string> displaydat)
{
int v = 0;
for(iter = displaydat.begin(); iter != displaydat.end(); ++iter)
{
switch(v)
{
case 0:
std::cout << "Title : ";
std::cout << *iter << std::endl;
v++;
break;
case 1:
std::cout << "Actor : ";
std::cout << *iter << std::endl;
v++;
break;
case 2:
std::cout << "Actor : ";
std::cout << *iter << std::endl;
v++;
break;
case 3:
std::cout << "Producer : ";
std::cout << *iter << std::endl;
v++;
break;
case 4:
std::cout << "Director : ";
std::cout << *iter << std::endl;
v++;
break;
case 5:
std::cout << "Production Company : ";
std::cout << *iter << std::endl;
v++;
break;
case 6:
std::cout << "Copies in Stock : ";
std::cout << *iter << std::endl;
v++;
break;
}
}
std::cout << std::endl;
}

void displaySub(CDList<std::string> displaydat)
{
int v = 0;
for(iter = displaydat.begin(); iter != displaydat.end(); ++iter)
{
switch(v)
{
case 0:
std::cout << "Name : ";
std::cout << *iter << std::endl;
v++;
break;
case 1:
std::cout << "IC : ";
std::cout << *iter << std::endl;
v++;
break;
case 2:
std::cout << "Address : ";
std::cout << *iter << std::endl;
v++;
break;
case 3:
std::cout << "Deposit : $";
std::cout << *iter << std::endl;
v++;
break;
}


}
std::cout << std::endl;

}


void listallvid()
{
std::cout << "VIDEO TITLE" << std::endl;
for(int a=1; a < vcounter+1; a++)
{
iter = Video[a].begin();
std::cout << *iter << std::endl;
}
}


void searchVid()
{
std::string element;
std::cout << "Please enter Video Title to search: ";
std::cin >> element;

for(int a=1; a < vcounter+1; a++)
{
iter = Video[a].begin();
if(*iter == element)
{
std::cout << "Video is available in store" << std::endl;
}
else
{
std::cout << "Video is not available in store" << std::endl;
}
}

}


void displayVidDetail()
{
std::string element;
std::cout << "Please enter Video Title to display: ";
std::cin >> element;

for(int a=1; a < vcounter+1; a++)
{
iter = Video[a].begin();
if(*iter == element)
{
displayX(Video[a]);

}
else
{
std::cout << "NO SUCH VIDEO!!!!" << std::endl;
}
}
}

void displaySubDetail()
{
std::string element;
std::cout << "Please enter Name of person to display: ";
std::cin >> element;

for(int a=1; a < scounter+1; a++)
{
iter = Subscriber[a].begin();
if(*iter == element)
{
displaySub(Subscriber[a]);

}
else
{
std::cout << "NO SUCH PERSON!!!!" << std::endl;
}
}
}


void returnVid()
{
bool found = false;
CDList<std::string> Rental2[100];
std::string element;
std::cout << "Please enter Rental NO: ";
std::cin >> element;
int counter = 1;
CDList temp;

for(int a=1; a < rcounter+1; a++)
{
iter = Rental[a].begin();
if(*iter == element)
{
if(rcounter == 1)
{
Rental[1] = temp;
rcounter--;
}
else
{
for(int x=1; x> element;
int d = 1;
int no = 1;
bool found = false;

std::cout << "VIDEO TITLE RENTED BY USER" << std::endl;
for(int a =1; a < rcounter+1; a++)
{

d = 1;
found = false;
for(iter = Rental[a].begin(); iter != Rental[a].end(); ++iter)
{
if(d == 2)
{
if(*iter == element)
found = true;
}
if(found == true)
{
if(d == 3)
{
std::cout << no << ") "<< *iter << std::endl;
no++;
}
}
d++;
}


}
}




anybody who can help to add on databse in side this program....databse you can use the text file or .dat file,just processing the simple read and write.......help help thank you man,

Comments

Sign In or Register to comment.