GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 15-Oct-2006, 23:46
mrdell_06 mrdell_06 is offline
New Member
 
Join Date: Feb 2006
Posts: 4
mrdell_06 is an unknown quantity at this point

do this in one day...i hope so


WXES1111: PRINCIPLES OF OBJECT-ORIENTED PROGRAMMING
SEM 1, 2006/2007
GROUP PROJECT 2

This problem is intended to be solved in a closed-lab session with your selected group member (2 persons). The problem is divided into FOUR parts: -

1. Lab Objectives
2. Description of the problem
3. Some examples of the menus
4. Problem-Solving Tips


Lab Objectives
This lab was designed to test your problem-solving skills and to reinforce your programming concepts from WXES1108 till WXES1111. In this lab, you will practice how to build real-life applications using the concepts learnt in object-oriented programming and in C++ file processing. It is crucial that you go through the software process life cycle, which is: -

• understanding the problem given
• analyzing and defining the requirements
• defining your analysis model, e.g. What are the text files that your require? What are the classes that you require to solve this problem? etc
• designing your solution, using either pseudo-code or flow chart
• coding your solution
• testing your solution


Description of the Problem

DVD Rental Shop System

You are a programmer working for XYZ Computing Network. You were assigned by your boss to build a simple C++ system for a client’s DVD Rental Shop. The DVD Rental Shop is owned by Encik Zuhaizy.

In order to obtain the requirements of the system that needs to be built, you interviewed Encik Zuhaizy in order to gather the functions that he wants the system to have. After the interview session, you made a list of the system requirements, as shown below: -

• Encik Zuhaizy would like to be able to enter information on new DVD titles that his shop has purchased, along with the number of copies for each DVD. An example of this information is given below: -
DVD Title : SHREK 2
Genre : Comedy
No. of copies : 5

• Encik Zuhaizy would like to display the list of DVD titles that is currently in his stock. He wants this information in a table format, as shown below: -
DVD Title No. of Copies
1. SHREK 2 5
2. THE INCREDIBLES 4
etc..

• Encik Zuhaizy would also like to be able to display the DVD titles under the same genre. For example: -
Genre: Comedy
DVD Titles: SHREK 2
THE INCREDIBLES
SHREK 1

• Encik Zuhaizy would also like to be able to display the current number of DVD copies in stock. For example: -
DVD Title: SHREK 2
No of copies (total): 5
No of copies (in stock): 3

• Encik Zuhaizy would like to use the system to record a customer’s loan of a DVD. Before a customer can loan a DVD, Encik Zuhaizy needs to first register the customer into the system. The information that is required for each customer is given below: -
Name: Abu Bakar bin Kasim Selamat
IC No: 679987-08-6632
Address: NO 16, Jalan Seta Kasih 3, Taman Seri Setia, 50603, Kuala Lumpur
Tel. no: 012-111222

• Once a customer has been registered, Encik Zuhaizy can now enter the DVD rental that the customer has requested. This process involves checking whether the DVD title is currently in stock. If there is a copy, then the customer may rent the DVD at RM3 per copy. If there are no copies left, an error message will be displayed showing that the shop currently has no copies of the DVD. The information needed for this transaction are: -
DVD Title : SHREK 2
IC No. : 679987-08-6632
Rental Date : 22 November 2004
Due Date : 27 November 2004

The list that you have made above is the requirements that you need to have in your system. But you may add other additional features into your system, as needed, such as displaying the list of registered customer, displaying the DVD titles that a customer has rented etc.


Some examples of the menu: -

ZUHAIZY DVD RENTAL SHOP
====== Main Menu =========
1. CUSTOMER
2. DVD
3. RENTAL
4. EXIT

Enter your choice (1-4): 1


ZUHAIZY DVD RENTAL SHOP
===== Customer Menu ======
1. ADD NEW CUSTOMER
2. DELETE CUSTOMER
3. DISPLAY CUSTOMER INFORMATION
4. DISPLAY ALL CUSTOMER
5. EXIT

Enter your choice (1-4):


Problem-Solving Tips

1. In order to ensure that your system is able to perform the necessary functions, you need to use C++ file processing. You need 3 test files: -
o A file to store customer’s information
o A file to store the DVD information
o A file to store the customer’s rental information

2. Use the example given below, to aid to in implementing file processing.

CPP / C++ / C Code:
/*A simple example to show how to use an object-oriented approach
to manage data on the name of a person. The list of names is stored
in a text file, named name.txt*/

#include <iostream.h>
#include <string.h>
#include <fstream.h>
#include <stdlib.h>

class Name {
char first[10];
char last[10];
public:
Name() { strcpy(first, "unknown"); strcpy(last, "unknown"); }
void setData(char f[], char l[]) { strcpy(first, f); strcpy(last, l); }
void display() {cout<<first<<" "<<last<<endl; }
char *getFirst() { return first; }
char *getLast() { return last; }
};

void main() {
//create temporary strings to store the first and last name read from the file
char temp1[10], temp2[10];
char sentence[10];

//create an array of Name object to store the names in the file
Name array[10];
int bil=0;//counter to count the number of names in file

fstream file("name.txt", ios::in | ios:ut);

if (!file){
cout<<"File cannot be opened!\n";
exit(1);
}

cout<<"The contents of the file:\n";
cout<<"-------------------------\n";
do{
file.getline(temp1, 10, '\n');//read from the file & store the values
file.getline(temp2, 10, '\n');//in the temporary strings
array[bil].setData(temp1, temp2); //assigning the values of the data read 
//to the private data of the class
bil++; //the number of names read
}while (!file.eof());

cout<<"\nThe contents of the file is: \n";
for (int i=0; i<bil; i++) //displaying the contents of the file
array[i].display();

cout<<endl<<endl<<"Input data to be inserted:\n"; //add another name
cout<<"------------------\n";
cout<<"First and last name: ";
cin>>temp1>>temp2;
array[bil].setData(temp1, temp2);
bil++;

file.clear();//copy back the list of names into the file
file.seekp(0);
for (i=0; i<bil; i++)
{
file<<array[i].getFirst()<<endl;

if (i == bil - 1)
file<<array[i].getLast();
else
file<<array[i].getLast()<<endl;
}

//displaying the new content of the file
cout<<endl<<endl<<"The new contents of the file:\n";
cout<<"-----------------------------\n";

file.clear();
file.seekg(0);
do{
file.getline(sentence, 10, '\n');
cout<<sentence<<endl;
}while (!file.eof());

cout<<endl;
file.close();
}

The text file: name.txt

Timmy
Rush
Venesa
Paradise
Britney
Spears
Ronald
McDonald



i got a template here....but didnt complete much...

CPP / C++ / C Code:
/* Template code for Project 2 */

#include <iostream.h>
#include <string.h>
#include <fstream.h>
#include <stdlib.h>
#include <ctype.h>
#include <iomanip.h>
#include <conio.h>

#define MAX 30

//TODO: DEFINE CLASS CUSTOMER

class Customer
{
private:
char *custName;
char *custIC;
char *custAdd;
char *custTelNo;
public:
Customer() 
{
custName = new char [30];
strcpy(custName, "unknown");
custIC = new char [15];
strcpy(custIC, "unknown");
custAdd = new char [50];
strcpy(custAdd, "unknown");
custTelNo = new char[12];
strcpy(custTelNo, "unknown");
}
void setData(char name[], char kp[], char add[], char tel[])
{
custName = new char [strlen(name) + 1];
strcpy(custName, name);
custIC = new char [strlen(kp) + 1];
strcpy(custIC, kp);
custAdd = new char [strlen(add) + 1];
strcpy(custAdd, add);
custTelNo = new char [strlen(tel) + 1];
strcpy(custTelNo, tel);
}
char* getName() const { return custName; }
char* getIC() const { return custIC; }
char* getAdd() const { return custAdd; }
char* getTelNo() const { return custTelNo; }
};




class DVD {
private:
char *title, *genre;
double total, inStock;
public:
DVD() 
{
title = new char [10];
strcpy(title, "unknown");
genre = new char [10];
strcpy(genre, "unknown");
total = 0;
inStock = 0;
}
void setData(char name[], char gen[], double tot, double stock)
{
title = new char [strlen(name) + 1];
strcpy(title, name);
genre = new char [strlen(gen) + 1];
strcpy(genre, gen);
total = tot;
inStock = stock;
}
char* getTitle() const { return title; }
char* getGenre() const { return genre; }
double getTotal() const { return total; }
double getStock() const { return inStock; }
};

//TODO: DEFINE CLASS RENTAL


//defining each function
int MainMenu() {
//function that displays the main menu
//user will choice the option that he/she wants
int input;
//system("color 4a");
cout<<"ZUHAIZY DVD RENTAL SHOP\n"
<<"====== Main Menu ======\n"
<<" 1. CUSTOMER\n"
<<" 2. DVD\n"
<<" 3. RENTAL\n"
<<" 4. EXIT\n\n"
<<"Enter your choice (1-4): ";
cin>>input;

while (input < 1 || input > 4) {
cout<<"\nYou have entered an illegal choice. Please try again.\n"
<<"Enter choice [1-4]: ";
cin>>input;
}

return input;
}

//TODO: DEFINE THE OPERATIONS FOR CUSTOMER MENU
//void CustomerMenu() 

//{
void CustomerMenu(Customer array[], int &bil) 
{
int ch, i, len;;
char custName[30], custIC[15];
char custAdd[50], custTelNo[12];
bool found = false;

do {
system("cls");
cout<<"=====Customer Menu========\n"
<<"1. ADD NEW CUSTOMER\n"
<<"2. DELETE A CUSTOMER\n"
<<"3. DISPLAY CUSTOMER INFORMATION\n"
<<"4. DISPLAY ALL CUSTOMER\n"
<<"5. MAIN MENU\n\n"
<<"Enter your choice: ";
cin>>ch;

while (ch < 0 || ch > 5) {
cout<<"Invalid choice! Please enter again [1-5]: ";
cin>>ch;
}

switch (ch) {
case 1: //add a new DVD
//prompt user for DVD information
cout<<"\n\nAdding a new customer\n"
<<"================\n"
<<"Enter customer information\n"
<<"Customer Name: ";
cin.ignore();
cin.getline(custName, 30, '\n');

//convert the title into capital letters
len = strlen(custName);
for (i=0; i < len; i++) {
if (islower(custName[i]))
custName[i] = toupper(custName[i]);
}

cout<<"IC No: ";
cin.ignore();
cin.getline(custIC, 15, '\n');
cout<<"Address: ";
cin.ignore();
cin.getline(custAdd, 50, '\n');
cout<<"Telephone No: ";
cin.ignore();
cin.getline(custTelNo, 12, '\n');

//insert the new DVD into the array
array[bil].setData(custName, custIC,custAdd, custTelNo);
bil++;
cout<<"The record has been successfully added...\n";
getch();
break;
case 2: //delete an existing DVD
cout<<"\n\nDeleting a customer\n"
<<"==============\n"
<<"Enter the name: ";
cin.ignore();
cin.getline(custName, 30, '\n');

//convert the title into capital letters
len = strlen(custName);
for (i=0; i < len; i++) {
if (islower(custName[i]))
custName[i] = toupper(custName[i]);
}

for (i = 0; i < bil; i++) {
if (!found)
if (strcmp(custName, array[i].getName()) == 0) {
found = true;
break;
}
}

//move the record one level up
if (found) {
for (int j=i; j<=bil-1; j++)
array[j].setData(array[j+1].getName(), array[j+1].getIC(), array[j+1].getAdd(), array[j+1].getTelNo());
bil--;
cout<<"The record has been successfully deleted...\n";
}
else
cout<<"There is no customer with that name\n";

break;
case 3: //display DVD information
cout<<"\n\nDisplaying a customer information\n"
<<"============================\n"
<<"Enter the customer name: ";
cin.ignore();
cin.getline(custName, 30, '\n');

//convert the title into capital letters
len = strlen(custName);
for (i=0; i < len; i++) {
if (islower(custName[i]))
custName[i] = toupper(custName[i]);
}

for (i = 0; i < bil; i++) {
if (!found)
if (strcmp(custName, array[i].getName()) == 0) {
found = true;
break;
}
}

if (found) {
cout<<"\nThe customer information\n"
<<"Customer Name: "<<array[i].getName()<<endl
<<"IC No: "<<array[i].getIC()<<endl
<<"Address: "<<array[i].getAdd()<<endl
<<"Telephone No: "<<array[i].getTelNo()<<endl
<<endl;
}
else
cout<<"There is no customer with that name\n";

cout<<"Press any key to continue...\n";
getch();
break;
case 4: //display all DVD
cout<<"\n\nDisplaying all customer information\n"
<<"==============================\n";
cout<<setw(30)<<"Name"<<setw(20)<<"IC No"<<setw(10)<<"Address"<<setw(10)<<"Telephone No"<<endl
<<setw(30)<<"====="<<setw(20)<<"====="<<setw(10)<< "====="<<setw(10)<<"====-"<<endl;

for (i=0; i<bil; i++){
cout<<setw(30)<<array[i].getName()
<<setw(20)<<array[i].getIC()
<<setw(10)<<array[i].getAdd()
<<setw(10)<<array[i].getTelNo()<<endl;
}
cout<<"Press any key to continue...\n";
getch();
break;
case 5: break;
}
} while (ch != 5);



}

void DVDMenu(DVD array[], int &bil) {
int ch, i, len;;
char title[30], genre[30];
double noCopies;
bool found = false;

do {
system("cls");
cout<<"=====DVD Menu========\n"
<<"1. ADD NEW DVD\n"
<<"2. DELETE A DVD\n"
<<"3. DISPLAY DVD INFORMATION\n"
<<"4. DISPLAY ALL DVD\n"
<<"5. MAIN MENU\n\n"
<<"Enter your choice: ";
cin>>ch;

while (ch < 0 || ch > 5) {
cout<<"Invalid choice! Please enter again [1-5]: ";
cin>>ch;
}

switch (ch) {
case 1: //add a new DVD
//prompt user for DVD information
cout<<"\n\nAdding a new DVD\n"
<<"================\n"
<<"Enter DVD information\n"
<<"DVD Title: ";
cin.ignore();
cin.getline(title, 30, '\n');

//convert the title into capital letters
len = strlen(title);
for (i=0; i < len; i++) {
if (islower(title[i]))
title[i] = toupper(title[i]);
}

cout<<"Genre: ";
cin.getline(genre, 20, '\n');
cout<<"Number of copies: ";
cin>>noCopies;

//insert the new DVD into the array
array[bil].setData(title, genre, noCopies, noCopies);
bil++;
cout<<"The record has been successfully added...\n";
getch();
break;
case 2: //delete an existing DVD
cout<<"\n\nDeleting a DVD\n"
<<"==============\n"
<<"Enter the DVD title: ";
cin.ignore();
cin.getline(title, 30, '\n');

//convert the title into capital letters
len = strlen(title);
for (i=0; i < len; i++) {
if (islower(title[i]))
title[i] = toupper(title[i]);
}

for (i = 0; i < bil; i++) {
if (!found)
if (strcmp(title, array[i].getTitle()) == 0) {
found = true;
break;
}
}

//move the record one level up
if (found) {
for (int j=i; j<=bil-1; j++)
array[j].setData(array[j+1].getTitle(), array[j+1].getGenre(), array[j+1].getTotal(), array[j+1].getStock());
bil--;
cout<<"The record has been successfully deleted...\n";
}
else
cout<<"There is no DVD with that title\n";

break;
case 3: //display DVD information
cout<<"\n\nDisplaying a DVD information\n"
<<"============================\n"
<<"Enter the DVD title: ";
cin.ignore();
cin.getline(title, 30, '\n');

//convert the title into capital letters
len = strlen(title);
for (i=0; i < len; i++) {
if (islower(title[i]))
title[i] = toupper(title[i]);
}

for (i = 0; i < bil; i++) {
if (!found)
if (strcmp(title, array[i].getTitle()) == 0) {
found = true;
break;
}
}

if (found) {
cout<<"\nThe DVD information\n"
<<"DVD Title: "<<array[i].getTitle()<<endl
<<"Genre: "<<array[i].getGenre()<<endl
<<"No. of copies: "<<array[i].getTotal()<<endl
<<"No. of copies currently available: "<<array[i].getStock()<<endl
<<endl;
}
else
cout<<"There is no DVD with that title\n";

cout<<"Press any key to continue...\n";
getch();
break;
case 4: //display all DVD
cout<<"\n\nDisplaying all DVD information\n"
<<"==============================\n";
cout<<setw(30)<<"Title"<<setw(20)<<"Genre"<<setw(1 0)<<"Total"<<setw(10)<<"Stock"<<endl
<<setw(30)<<"====="<<setw(20)<<"====="<<setw(10)<< "====="<<setw(10)<<"====-"<<endl;

for (i=0; i<bil; i++){
cout<<setw(30)<<array[i].getTitle()
<<setw(20)<<array[i].getGenre()
<<setw(10)<<array[i].getTotal()
<<setw(10)<<array[i].getStock()<<endl;
}
cout<<"Press any key to continue...\n";
getch();
break;
case 5: break;
}
} while (ch != 5);
}

//TODO: DEFINE THE OPERATIONS FOR RENTAL MENU
void RentalMenu() 
{

}

void main() 
{

//TODO: READ FROM CUSTOMER FILE AND INPUT INTO CUSTOMER ARRAY
char tmpName[30], tmpIC[15], tmpAdd[50], tmpTelNo[12];
//double tmpTotal, tmpStock;
int bilCustomer = 0;//counter to count the number of names in file
Customer arrayCustomer[10];

fstream file("Customer.txt", ios::in | ios:ut);

if (!file){
cout<<"File cannot be opened!\n";
exit(1);
}

do{
//read from the file & store the values in the temporary strings
file.getline(tmpName, 30, '\n');
file.getline(tmpIC, 15, '\n');
file.getline(tmpAdd, 50, '\n');
file.getline(tmpTelNo, 12, '\n');
//convert string type to double
// tmpTotal = atof(tmpT);
// tmpStock = atof(tmpS);
//assigning the values of the data read to the private data of the class
arrayCustomer[bilCustomer].setData(tmpName, tmpIC, tmpAdd, tmpTelNo); 
bilCustomer++; //the number of records read
}while (!file.eof() && bilCustomer < MAX);



//reading from DVD.txt file and input into DVD array===========
char tmpTitle[30], tmpGenre[30], tmpT[8], tmpS[8];
double tmpTotal, tmpStock;
int bilDVD = 0;//counter to count the number of names in file
DVD arrayDVD[10];

fstream DVD("DVD.txt", ios::in | ios:ut);

if (!DVD){
cout<<"File cannot be opened!\n";
exit(1);
}

do{
//read from the file & store the values in the temporary strings
DVD.getline(tmpTitle, 30, '\n');
DVD.getline(tmpGenre, 30, '\n');
DVD.getline(tmpT, 8, '\n');
DVD.getline(tmpS, 8, '\n');
//convert string type to double
tmpTotal = atof(tmpT);
tmpStock = atof(tmpS);
//assigning the values of the data read to the private data of the class
arrayDVD[bilDVD].setData(tmpTitle, tmpGenre, tmpTotal, tmpStock); 
bilDVD++; //the number of records read
}while (!DVD.eof() && bilDVD < MAX);


//TODO: READ FROM RENTAL FILE AND INPUT INTO RENTAL ARRAY

int choice;
do 
{
system("cls");
choice = MainMenu();

switch (choice) {
case 1: CustomerMenu(arrayCustomer, bilCustomer);
break;
case 2: DVDMenu(arrayDVD, bilDVD);
break;
case 3: RentalMenu();
break;
case 4: cout<<"\nTerminating program...\n\n";
} 
}while (choice != 4);

//once operations are completed, copy the arrays back into their respective files
//TODO: COPY CUSTOMER ARRAY INTO CUSTOMER TEXT FILE
file.clear();
file.seekp(0);
for (int i=0; i<bilCustomer; i++)
{
file<<arrayCustomer[i].getName()<<endl;
file<<arrayCustomer[i].getIC()<<endl;
file<<arrayCustomer[i].getAdd()<<endl;
file<<arrayCustomer[i].getTelNo()<<endl;

//writing the last line
if (i == bilCustomer - 1)
file<<arrayCustomer[i].getName();
else
file<<arrayCustomer[i].getName()<<endl;
}

//copying DVD array into DVD.txt file
DVD.clear();
DVD.seekp(0);
for ( i=0; i<bilDVD; i++)
{
DVD<<arrayDVD[i].getTitle()<<endl;
DVD<<arrayDVD[i].getGenre()<<endl;
DVD<<arrayDVD[i].getTotal()<<endl;

//writing the last line
if (i == bilDVD - 1)
DVD<<arrayDVD[i].getStock();
else
DVD<<arrayDVD[i].getStock()<<endl;
}


//TODO: COPY RENTAL ARRAY INTO RENTAL TEXT FILE

}

//for the above program, i got a problem using the rental program..and when i want to add customer and dvd..it cannot display in command prompt when i to display customer/dvd information...so i just can add one customer/dvd

and also another template...

CPP / C++ / C Code:
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <conio.h>
#include <windows.h>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <string>
using namespace std;

class Customer
{

private:
string word;


protected:

char name[100]; 
char ICNo[100];
char add[100];
char telNo[100];

public:

void custMenu();
void addCust();
void deleteCust();
void displayCustInfo();
// void displayAllCust();

};

void Customer::custMenu()
{

char choice;

do
{
do
{

cout<< "\t\t\t ************************************ " <<endl;
cout<< "\t\t\t ** ZUHAILY DVD RENTAL SHOP ** " <<endl;
cout<< "\t\t\t ************************************ " <<endl;


cout<< " CUSTOMER MENU " <<endl;
cout<< " ***************** " <<endl;
cout<< "\n 1) Add New Customer " <<endl;
cout<< " 2) Delete Customer " <<endl;
cout<< " 3) Display Customer Information " <<endl;
cout<< " 4) Display All Customer " <<endl;
cout<< " 5) Exit " <<endl;
cout<<endl;

cout<< " Enter your choice [1-5] : ";
cin>>choice;

system("cls");

} while(choice!='1' && choice!='2' && choice!='3' && choice!='4' && choice!='5');


switch(choice)
{
case '1':
{
addCust();
system("cls");
break;
}

case '2':
{
deleteCust();
system("cls");
break;
}

case '3':
{
displayCustInfo();
system("cls");
break;
}

case '4':
{
// displayAllCust();
system("cls");
break;
}

case '5':
{
return;
break;
}
}

}while(choice!='5');

}



void Customer::addCust()
{

char quest;

do{

system("cls");

string newWord;
char input[100];

cout<<"\t\t+====================================== ========+\n";
cout<<"\t\t| CUSTOMER INFO |\n";
cout<<"\t\t+====================================== ========+\n";

cout<<"\n\t\tEnter 0 to Exit\n";

cout<<"\n\t\tName : ";
cin.ignore();
cin.getline(input,100);

if(strcmp(input,"0")==0) 
return;

newWord=input;
for(int a=0; a<newWord.length(); a++)
newWord[a]=toupper(newWord[a]);

cout<<"\n\t\tICNo : ";
cin.getline(input,100);

if(strcmp(input,"0")==0) 
return;

newWord=newWord+'/'+input;

cout<< "\n\t\tAddress : ";
cin.getline(input,100);

if(strcmp(input,"0")==0) 
return;
newWord=newWord+'/'+input;

for(int b=0; b<newWord.length(); b++)
newWord[b]=toupper(newWord[b]);

cout<< "\n\t\tTelNo : ";
cin.getline(input,100);

if(strcmp(input,"0")==0) 
return;
newWord=newWord+'/'+input;

ofstream file("cust.txt",ios::app);
file<<"\n"<<newWord;
file.close();

cout<<"\n\n\t\tThe details had been added into file successfully! \n\n\t\t";


cout << "\n\tDo You Want to Add Another Customer's Info? [Y/N]: ";
cin >> quest;
cout<<endl;

} while ( quest != 'n' && quest != 'N'); 

system("PAUSE");
}


void Customer::deleteCust()
{
system("cls");

int choice,i=1;
string word;

cout<<"\t\t+====================================== ========+\n";
cout<<"\t\t| DELETE CUSTOMER INFO |\n";
cout<<"\t\t+====================================== ========+\n";

cout<<"\n\t\tEnter 0 to Exit\n";
ifstream infile("cust.txt");

while(!infile.eof()){
getline(infile,word);
string word2;

for(int j=0; j<word.length(); j++){
if(word[j]=='/')
break;
word2+=word[j];
}
cout<<"\n\t\t"<<i<<"=>"<<word2;
i++;
}
infile.close();
cout<<"\n\n\t\tPlease Choose Your Choice => ";
cin>>choice;
flushall();
if(choice==0)
return;
else if(choice>i+1 || choice<0)
deleteCust();

else{
string Words[100],temp; 
int k=0,m=0;
ifstream infile2("cust.txt");
while(!infile2.eof()){
getline(infile2,temp);
if(m!=choice-1){
Words[k]=temp;
k++;
}
m++;
}
infile2.close();
ofstream infile3("cust.txt",ios:ut);
for(int n=0; n<k; n++){
infile3<<Words[n];
if(n+1!=k)
infile3<<"\n";
}

cout<<"\n\n\t\tThe detail had been deleted from file successfully! \n\n\t\t";
system("PAUSE");
}

}

void Customer::displayCustInfo()
{
char buffer[50];

ifstream file("cust.txt",ios::in);
system("cls");

if (!file) 
{
cout << "Error opening input file" << endl;
exit(-1); 
}

cout << "\t\t\t List of Customer's Information " <<endl;
cout << "\t\t\t**********************************" <<endl;
cout<<endl;
while (!file.eof())
{
file.getline(buffer,50);
cout<<buffer<<endl;
cout<<endl;
}

system("PAUSE");
file.close();
return;

}


/*void Customer::displayAllCust()
{

cout<<"\t\t+====================================== ========+\n";
cout<<"\t\t| DISPLAY ALL CUSTOMER |\n";
cout<<"\t\t+====================================== ========+\n";


}
*/


class DVD{

protected:

char genre[50];
int quantity;

public:

void DVDmenu();
void addDVD();
void deleteDVD();
void displayDVDInfo();
// void displayGenre();


};


void DVD:VDmenu()
{

char choice;

do
{
do
{

cout<< "\t\t\t ************************************ " <<endl;
cout<< "\t\t\t ** ZUHAILY DVD RENTAL SHOP ** " <<endl;
cout<< "\t\t\t ************************************ " <<endl;


cout<< " DVD MENU " <<endl;
cout<< " ***************** " <<endl;
cout<< "\n 1) Add New DVD " <<endl;
cout<< " 2) Delete DVD " <<endl;
cout<< " 3) Display all DVD " <<endl;
cout<< " 4) Display According Genre " <<endl;
cout<< " 5) Exit " <<endl;
cout<<endl;

cout<< " Enter your choice [1-5] : ";
cin>>choice;

system("cls");

} while(choice!='1' && choice!='2' && choice!='3' && choice!='4' && choice!='5');


switch(choice)
{
case '1':
{
addDVD()
;
system("cls");
break;
}

case '2':
{
deleteDVD();
system("cls");
break;
}

case '3':
{
displayDVDInfo();
system("cls");
break;
}

case '4':
{
// displayGenre();
system("cls");
break;
}

case '5':
{
return;
break;
}
}

}while(choice!='5');

}

void DVD::addDVD()
{

char choice;

do{

system("cls");

string newWord;
char input[100];

cout<<"\t\t+====================================== ========+\n";
cout<<"\t\t| DVD INFORMATION |\n";
cout<<"\t\t+====================================== ========+\n";

cout<<"\n\t\tEnter 0 to Exit\n";

cout<<"\n\t\tTitle : ";
cin.ignore();
cin.getline(input,100);

if(strcmp(input,"0")==0) 
return;
newWord=input;

for(int a=0; a<newWord.length(); a++)
newWord[a]=toupper(newWord[a]);

cout<<"\n\t\tGenre : ";
cin.getline(input,100);

if(strcmp(input,"0")==0) 
return;
newWord=newWord+'/'+input;

for(int b=0; b<newWord.length(); b++)
newWord[b]=toupper(newWord[b]);

cout<< "\n\t\tNo of copies : ";
cin.getline(input,100);

if(strcmp(input,"0")==0) 
return;
newWord=newWord+'/'+input;



ofstream file("dvd.txt",ios::app);
file<<"\n"<<newWord;
file.close();

cout<<"\n\n\t\tThe details had been added into file successfully! \n\n\t\t";


cout << "\n\tDo You Want to Add Another Customer's Info? [Y/N]: ";
cin >> choice;
cout<<endl;

} while ( choice != 'n' && choice != 'N'); 

system("PAUSE");
}


void DVD::deleteDVD()
{
system("cls");

int choice,i=1;
string word;

cout<<"\t\t+====================================== ========+\n";
cout<<"\t\t| DELETE DVD INFORMATION |\n";
cout<<"\t\t+====================================== ========+\n";

cout<<"\n\t\tEnter 0 to Exit\n";
ifstream infile("dvd.txt");

while(!infile.eof()){
getline(infile,word);
string word2;

for(int j=0; j<word.length(); j++){
if(word[j]=='/')
break;
word2+=word[j];
}
cout<<"\n\t\t"<<i<<"=>"<<word2;
i++;
}
infile.close();
cout<<"\n\n\t\tPlease Choose Your Choice => ";
cin>>choice;
flushall();
if(choice==0)
return;
else if(choice>i+1 || choice<0)
deleteDVD();

else{
string Words[100],temp; 
int k=0,m=0;
ifstream infile2("dvd.txt");
while(!infile2.eof()){
getline(infile2,temp);
if(m!=choice-1){
Words[k]=temp;
k++;
}
m++;
}
infile2.close();
ofstream infile3("dvd.txt",ios:ut);
for(int n=0; n<k; n++){
infile3<<Words[n];
if(n+1!=k)
infile3<<"\n";
}

cout<<"\n\n\t\tThe detail had been deleted from file successfully! \n\n\t\t";
system("PAUSE");
}

}

void DVD::displayDVDInfo()
{
char buffer[50];

ifstream file("dvd.txt",ios::in);
system("cls");

if (!file) 
{
cout << "Error opening input file" << endl;
exit(-1); 
}

cout<<endl;
cout << "\t\t\t List of DVD's Information " <<endl;
cout << "\t\t\t**********************************" <<endl;

while (!file.eof())
{
file.getline(buffer,50);
cout<<buffer<<endl;
cout<<endl;
}

system("PAUSE");
file.close();
return;

}

/*void DVD::displayGenre()
{



}
*/


class Rental{

protected:

// char r_date[20];
// char d_date[20];

public:

void RentalMenu();


};


void Rental::RentalMenu()
{
char choice;

do
{
do
{

cout<< "\t\t\t ************************************ " <<endl;
cout<< "\t\t\t ** ZUHAILY DVD RENTAL SHOP ** " <<endl;
cout<< "\t\t\t ************************************ " <<endl;


cout<< " RENTAL MENU " <<endl;
cout<< " ***************** " <<endl;
cout<< "\n 1) Add Rental Info " <<endl;
cout<< " 2) Display" <<endl;
cout<< " 3) Exit " <<endl;
cout<<endl;

cout<< " Enter your choice [1-3] : ";
cin>>choice;

system("cls");

} while(choice!='1' && choice!='2' && choice!='3');


switch(choice)
{
case '1':
{
// addRental();
system("cls");
break;
}

case '2':
{
// displayRental();
system("cls");
break;
}

case '3':
{
return;
break;
}
}

}while(choice!='3');

}




void main(){

Customer y;
DVD z;
Rental q;


int x;


do{

do{

cout<< "\t\t\t ************************************ " <<endl;
cout<< "\t\t\t ** ZUHAILY DVD RENTAL SHOP ** " <<endl;
cout<< "\t\t\t ************************************ " <<endl;

cout<< " MAIN MENU " <<endl;
cout<< " ************** " <<endl;

cout<< "\n 1) Customer " <<endl;
cout<< " 2) DVD " <<endl;
cout<< " 3) Rental " <<endl;
cout<< " 4) Exit " <<endl;

cout<< "\n Enter your choice [1-4] : ";
cin>>x;

cin.ignore(1,'\n');
cout<<endl;
system("cls");

}while(x!=1 && x!=2 && x!=3 && x!=4);



switch(x)

{
case 1:
y.custMenu();
system("cls");
break;

case 2:
z.DVDmenu();
system("cls");
break;

case 3:
q.RentalMenu();
system("cls");
break;

default:
break;
}

}while(x!=4);


cout<<endl;
cout<< " \3\3\3\3\3 Thank You! \3\3\3\3\3 " <<endl;
cout<<endl<<endl;
}
Last edited by LuciWiz : 16-Oct-2006 at 12:30. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 16-Oct-2006, 08:19
edt edt is offline
New Member
 
Join Date: Aug 2006
Posts: 26
edt is on a distinguished road

Re: do this in one day...i hope so


yeah...right...
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
My first thread and i hope that u help me ^_^ Comp_Lover C++ Forum 11 03-May-2006 16:02
I hope this the right forum, java help for student sammy78 Java Forum 0 08-Mar-2006 15:44
The Traps of Linux...&open source software michael Open Discussion Forum 6 22-May-2004 03:05
randomness ambeco C++ Forum 19 05-Feb-2004 21:24
I Hope I'll have a good stay here :) cityit New Member Introductions 2 28-Dec-2003 23:49

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:07.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.