Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 118

Movie Planet

Major Project

submitted in partial fulfillment of the requirement for


the award of the degree of

Bachelor of Science
In

Information Technology

By

Samarth Vip
Enroll. No. A50504914032

Under the guidance of


Ms. Ashima Gambhir

Department of Information Technology


Amity Institute of Information Technology
Amity University Haryana
Gurgaon, India
June, 2019
Department of Information Technology
Amity Institute of Information Technology

Declaration

I, Samarth Vip, Enroll. No. A50504914032, student of Bachelor of Technology


(or Master of Computer Applications) in Department of Computer Science and
Engineering, Amity School of Engineering and Technology, Amity University Haryana,
hereby declare that I am fully responsible for the information and results provided in this
project report titled “Movie Planet” submitted to Department of Information Technology,
Amity Institute of Information Technology, Amity University Haryana, Gurgaon for the
partial fulfilment of the requirement for the award of the degree of Bachelor of Science
in Information Technology. I have taken care in all respects to honour the intellectual
property rights and have acknowledged the contributions of others for using them. I
further declare that in case of any violation of intellectual property rights or copyrights, I
as a candidate will be fully responsible for the same. My supervisor, Head of department
and the Institute should not be held for full or partial violation of copyrights if found at
any stage of my degree.

Signature(s)

Samarth Vip
Enroll No.: A50504914032
Department of Information Technology
Amity Institute of Information Technology

Certificate

This is to certify that the work in the project report entitled “Movie Planet” by Samarth
Vip bearing Enroll. No. A50504914032 is a bonafide record of project work carried out
by him under my supervision and guidance in partial fulfillment of the requirements for
the award of the degree of Bachelor of Science (Information Technology) in the
Department of Information Technology, Amity Institute of Information Technology,
Amity University Haryana, Gurgaon. Neither this project nor any part of it has been
submitted for any degree or academic award elsewhere.

Signature of Supervisor(s)

Date: Name & Designation

Head
Department of Information Technology
Amity Institute of Information Technology
Amity University Haryana, Gurgaon
CONTENTS
TITLE PAGE NO.

CHAPTER 1: INTRODUCTION 1

1.1 OBJECTIVES AND SCOPE 1

1.2 DEFINITION OF THE PROBLEM 2

CHAPTER 2: BACKGROUND OF THE PROJECT 4

CHAPTER 3: TECHNOLOGY USED 5

CHAPTER 4: DESIGN OF THE PROJECT 7

CHAPTER 5: IMPLEMENTATION 18

CHAPTER 6: SCREEN SHOTS 28

CHAPTER 7: CODING 57

CHAPTER 8: RESULTS & CONCLUSION 111

REFERENCES 112
CHAPTER 1

INTRODUCTION

1.1 OBJECTIVES AND SCOPE

This project facilitates keeping records of CDs and customers in a systematic and easily
accessible manner with hundred percent accuracy .It also show all CDs and customers
listing whenever needed.

Efficiency wise the software makes efficient use of system resources such as memory.
The accuracy of the system is up to the mark. It can also be used by the customer to get
all updated collection information from the video parlor.

 All CDs and customer records are updated with each transaction to keep the
system up to date.

 All CDs and customers are having a unique id by which they are recognized.

 Fine is charged after skipping the date of return of the CD by the customer at the
rate of Rs.2 per day.

 It makes data handling very easy.

 Increments or decrements the required records after each transaction.

This software automates almost all the activities of the video parlor that
could be automated. It provides a conducive environment to the person
working there. It has made work simpler and easier. Now one can work more
efficiently and with more interest without wasting much of his/her time.

1
1.2 DEFINITION OF THE PROBLEM

At present all the activities of the video parlors like adding, modifying and deletion of
new CDs and customers were done manually. Cumulative information like total copies of
a particular CD are also maintained manually in the registers for the transactions being
made.

Problem with the current system —

Since the existing system is manual one, the owner has to face many difficulties
everyday. Some of the difficulties are as follows-

 Difficulty and time consumption in entering each and every transaction.

 Difficulty keeping records.

 There are chances of wrong totaling.

 Book keeping is a cumbersome job.

 Difficulty in adding, modifying and deleting records from registers.

How Computerization is going to help:-

Computerization helps us address these problems. Stated below are some of the
advantages using computers instead of manual work-

 It has provision of allowing only authentic users having access to database. So the
problem of security is dealt with.

 Data validation is also possible as the computer automatically prompt an error if


any arbitrary data is entered.

 There is no need of large amount of stationary paper as all the data is entered into
the computer.

2
 List generation of CDs also becomes very easier as there is no need for any
manual paper work.

3
CHAPTER 2

BACKGROUND OF THE PROJECT

The various issues that were brought to light to light! Inventory System for New Era-CD
Library Shop beggar in for a computerized sales monitoring system to increase the
efficiency of the operation department, first of all. Complete details about the customer
must be maintained. This will left up to know how much is due from any given credit
customer and when his credit period expires for the last purpose apart from this complete
details abort product are also to be maintained. This will help identify the product, which
are low in collection and objectives to be meet; we need to record for these objectives to
be meet. We need to record all the transaction and also update the and product various
tasks can be looked and below:-

1. Maintaining customer related information.

2. Maintaining product related information.

3. Recording all the transaction.

4. Handling customer payment

5. Update of collection at the time of selling

6. Update of collection at the time of the receipt of materials

7. Daily sells report

8. Non moving Musics report

9. Report on Credit

4
CHAPTER 3

TECHNOLOGY USED

C++ is an Object Oriented Programming Language. It was developed by Bjarne


Stroustrup at AT & T Bell Labouratries in Murry Hill, New Jersy, and USA in early 1980.
C++ is an extension of C with a major addition of the class construct feature of Simula
67.
The most important facilities that C++ adds on to C are Classes, Inheritence,
Function overloading and Operator overloading. These features enable creating of
abstract data types, inherit properties from existing data types and support polymorphism,
there was a making C++ a truly Object Oriented Language.
The Object Oriented Features in C++ allow Programmers to build large programs
with clarity, extensibility and easy to maintenance, incorporating the sprit and efficiency
of C.

APPLICATION OF C++
a. C++ is a versatile language for handling very large programs. It is suitable
for virtually any programming task including development of editors, compilers,
database communication systems and any real life application systems.
b. Since, C++ allows us to create hierarchy related objects, we can build
special object oriented libraries which can be used later by many programmers.

c. C++ programs are easily maintainable and expandable when a new


features needs to be implemented, it is a very easy to add to the existing structure
of the object.

Introduction to Software Selection


Software selection is a critical aspect of system development. There are two ways of
acquiring software: custom- made or "off-the-shelf" package Today, there is great
demand for these packages because they are quite cheap. There are other benefits also.

5
1. A good package can get the system running quickly.
2. MIS personnel are released for other projects.
3. 'Home-grown' software can take more time and its cost cannot be predicted.
4. Package can be tested before purchasing it.

Some drawbacks of software packages are:


1. These packages may not meet user requirements in all respect.
2. Extensive modifications of a package usually results in loss of the vendor's
support.

It can be observed that price alone cannot determine the quality of software. A systematic
review is crucial for selecting the desired software. Prior to selecting the software, the
project team must set up criteria for selection.

The criteria for software selection are:


1. Reliability: gives consistent results without any failure for a specified time period.
2. Functionality: functions to standards.
3. Capacity: satisfies volume requirements of the user.
4. Flexibility: adapts to the changing needs
5. Usability: is user-friendly.
6. Security: maintains integrity and prevents unauthorized user.
7. Performance: delivers the results as expected.
8. Serviceability: has good documentation and vendor support.
9. Ownership: has right to modify and share use of package.
10. Minimal costs: is justified and affordable for intended application.

6
CHAPTER 4
DESIGN OF THE PROJECT

HARDWARE AND SOFTWARE REQUIREMENT’S


Hardware:-
AMD Athlon(tm) P 1900+
20 GB Hard disk or above
256 MB RAM
Display Monitor 15 inch
Multimedia Keyboard
UPS (Uninterrupted power Supply)

Software:-
Windows XP
C++ (Turbo C++)

USER REQUIREMENT
Users for their assistance in running the project successfully must have following
necessities.
1. Fundamental knowledge of basic computer operations.
2. User must read the user manual supplied with the project.
3. Users must not try and run the project below the specified conditions.
DATA DICTIONARY
A data dictionary is a catalog – a repository – of the elements in a system. As the
name suggests, these elements center around data and the way they are structured to meet
the user requirements and organization needs. In a data dictionary, you will find a list of
all the elements composing the data flowing through a system. The major elements are
data flows, data stores and processes. The data dictionary stores details and descriptions
of these elements.

7
-DATA FLOW DIAGRAM’S-

Data Flow Diagrams provide a logical model of the system and show the flow of logic
involved in the proposed\present system.

-CONTEXT LEVEL D.F.D-

CUSTOMER

CD’S PAYMENTS

Movie
Planet

DETAILS

OWNER

8
-TOP LEVEL D.F.D -

1.Introduction
7.Exit
CD.DAT

Customer.dat

Details
About6.Edit Records 2.Add CD to collection
Exit the s/w

New cd
Data

6.Customers Main Menu


Catalog (Movie Planet) 3.Add Customer

Customers
list

Details

Customer.dat Cds list CD


5.CDs catalog data 4.Issue a CD

5.Return CD

Details Update

CD.DAT

Update CD.dat Customer.dat

9
DFD FOR ADDITION OF NEW CD

Owner CD.dat

Input details
If O.K
1.validation checks
If not O.K
Error message

New record
2. Updatefiles

10
DFD FOR ADDITION OF NEW CUSTOMER

Owner Customer.dat

Input
details If O.K
1.Validation checks
If not O.K
Error message

New record
2.Update files

11
DFD FOR ISSUE A CD

Required Data or Customer & CD.dat


CUSTOMER Cash

1. Data processed
Amount Update record

12
DFD FOR CD RETURN

Customer.dat & CD.dat


CUSTOMER
Cash (Fine)

Movie planet
Fine Update record

13
-D.F.D FOR CD CATALOG-

1.
Enter
Suitable
Choice

processing

2.
detail
open CD.dat
file CD.dat

processing

3.
display
information

14
-D.F.D FOR CUSTOMERS CATALOG-

1.
Enter
suitable
choice

processing

2.
detail
open customer.dat
customer.dat

processing

3.
display
information

15
-D.F.D FOR DELETION OF CD RECORD-

2.
1. accepts
Owner Request for DISPLAY & check
deletion LIST. record

details
verification
CD.dat
details

update
3.
prompts
CD.dat to delete
update

16
-D.F.D FOR DELETION OF CUSTOMER -

2.
1. accepts
Owner Request for DISPLAY & check
deletion LIST. record

details
verification
customer.dat
details

update
3.
prompts
customer.dat to delete
update

17
CHAPTER 5
IMPLEMENTATION

-FLOW CHART-

START

1.INTRODUCTION
2.ADD CD TO COLLECTION
3.ADD A CUSTOMER
4.ISSUE A CD
5.RETURN CD
6.CD CATALOG
7.CUSTOMERS CATALOG
8.EDIT
0.EXIT

READ CH(CH)

YES
introduction()
IFCH=
1
YES add_cd()

IF
CH=2
YES add_member()

IF
CH=3
YES
issuecd()
IF
CH=4
YES
returncd()
IF
CH=5
18
C
C

YES
IF CH=6 list()

YES
IF CH=7 list()

YES
IF CH=8 edit_menu()

NO YES
A IF CH=0 STOP

19
-MENU DESIGNS-

MAIN MENU:
INTRODUCTION
OWNER

ADD CD TO
COLLECTION

ADD CUSTOMER

ISSUE CD

RETURN CD

CD CATALOG

CUSTOMER
CATALOG

EDIT

EXIT

-EDIT RECORDS MENU-


20
OWNER EDIT RECORDS MENU EDIT CD RECORD

EDIT CUSTOMER
RECORD

EXIT

EDIT CD RECORD MENU


21
EDIT CD RECORD MENU
MODIFY CD RECORD

DELETE CD RECORD

EXIT

22
EDIT CUSTOMER RECORD MENU

EDIT CD RECORD MENU


MODIFY CUSTOMER
RECORD

DELETE CUSTOMER
RECORD

EXIT

23
-DATA DICTIONARY-

class MENU :- THIS CLASS CONTROL ALL THE FUNCTIONS IN THE MENU
{
public :
void main_menu(void) ; TO SHOW MAIN MENU
void introduction(void) ; TO SHOW INTRO MENU
private :
void edit_menu(void) ; TO SHOW EDIT MENU
void edit_cd(void) ; TO SHOW EDIT CD MENU
void edit_member(void) ; TO SHOW EDIT CUSTOMER

MENU
};

class CD THIS CLASS CONTAINS FUNCTIONS RELATED TO CUSTOMERS


{
public :
int cdcode, copies ;
void list(void) ;
char *cdname(int) ;
protected :
void add_new_cd(int, char tname[33], char tcopyright[26],
float, int, int) ; TO ADD NEW CD
void update_copies(int, int, int) ; TO ADD COPIES
void modify(int, char[], char[], float) ; TO MODIFY CD REC
void deletion(void) ; TO DELETE CD REC
int cd_found(int) ; TO CHECK CD’S PRESENCE
int cdname_found(char []) ; TO CHECK CD’S PRESENCE

int recordno(int) ;
int available(int) ; TO CHECK CD’S AVALAIBILITY
char *year(int) ;
float cdprice(int) ; FOR CD PRICE
int no_of_copies(int) ;FOR NO. OF COPIES
int cdcodeof(char[]) ; FOR CD CODE
void display(int) ; FOR DISPLAY REC
int reccount(void) ;
void delete_rec(int) ; FOR DELETION OF REC

private :

24
char name[33], copyright[26] ;
float price ;
int avail ;

};

class CUSTOMER
{
public :
void list(void) ; FOR CD CATALOG
int cdcode;
CUSTOMER(){cdcode=0;}
protected :
void add_mem(int, int, char [], char [], char[], int, int,int);

void modify(int, char[], char[], char[]) ; MODIFYING REC


void deletion(void) ; FOR DELETING REC.
int member_found(int) ; TO CHECK
CUSTOMERSPRESENCE
void update_cd(int, int, int, int, int) ;
char *membername(int) ;
char *memberphone(int) ;
char *memberaddress(int) ;
int recordno(int) ;
int lastcode(void) ; TO GET LAST CUSTOMER CODE
int issued(int) ; TO CHECK A CD IS ISSUED
int fine(int) ; TO CHARGE FINE
void display(int) ;
void delete_rec(int) ;TO DELETE A REC.
private :
int memcode ;
char name[26], phone[10], address[50] ;
int dd, mm, yy ; // DATE OF RETURNING THE CD //
};

25
CUSTOMER THIS IS DERIVED FROM CLASS CD & CUSTOMER AND
CONTAINS FUNCTIONS FOR WORKING (ISSUE,RETURN,ETC).
class WORKING : public CD, public
{
public :
void issuecd(void) ;
void returncd(void) ;
void add_cd(void) ;
void add_member(void) ;
void modify_cd(void) ;
void modify_member(void) ;
void delete_cd(void) ;
void delete_member(void) ;
};

THIS CLASS CONTAINS FUNCTIONS RELATED DATE & FINE

class DATE
{
public :
void extend_date(int,int,int,int) ;
int diff(int, int, int, int, int, int) ;
int day, mon, year ;
};

26
-HEADER FILES USED-

IOSTREAM.H Declares the basic C++ (version 2.0) streams (I/O) routines.

PROCESS.H Contains structures and declarations for the spawn... and exec...
functions.
STDLIB.H Declares several commonly used routines: conversion routines,
search/sort routines, and other miscellany.
STDIO.H Defines types and macros needed for the Standard I/O Package.
Defines the standard I/O predefined streams stdin, stdout, stdprn,
and stderr, and declares stream-level I/O routines.
CTYPE.H Contains information used by the character classification and
character conversion macros
CONIO.H Declares various functions used in calling the DOS console I/O
routines.
DOS.H Defines various constants and gives declarations needed for DOS
calls.
STRING.H Declares several string- and memory-manipulation routines
FSTREAM.H Declares the C++ stream classes that support file input and output

27
CHAPTER 6
SCREEN SHOTS

-INTRODUCTION SCREEN-

______________________________________________

W E L C O M E T O T H E M O V I E P LAN E T
______________________________________________

MADE BY:- SMARTH VIP

* THIS PROJECT WILL FACILITATE KEEPING RECORDS OF


CD'S AND CUSTOMERS IN A SYSTEMATIC AND EASILY
ACCESSIBLE MANNER.

* CHARGES FINE AFTER SKIPPING THE DATE OF RETURN


@ Rs.2 PER DAY.

* LISTS CDs AND CUSTOMERS RECORDS

PRESS ANY KEY TO RUN THE PROJECT

28
MAIN MENU

_______________________________________________

M O V I E S P LAN E T
_______________________________________________

1. INTRODUCTION
2. ADD CD TO COLLECTION
3. ADD A CUSTOMER
4. ISSUE A CD
5. RETURN CD
6. CDs CATALOG
7. CUSTOMERS CATALOG
8. EDIT RECORDS
0. EXIT

_______________________________________________

ENTER A SUITABLE CHOICE

29
ADDITION OF CD’S MENU

EXIT (0)

ADDITION OF THE CD's


_____________________________________________________________________
CODE NO. 1

CD NAME : DHOOM
COPYRIGHT: HMV
PRICE : Rs.200

COPIES :5

SAVE THIS RECORD? (Y/N):

30
ADDITION OF CUSTOMERS MENU

EXIT (0)

ADDITION OF THE CUSTOMERS

_____________________________________________________________________
CUSTOMER CODE : 1
_____________________________________________________________________

NAME : smarth

PHONE : 23655043

ADDRESS: SHASTRI NAGAR

SAVE THIS RECORD (Y/N):_

31
ISSUE A CD MENU

EXIT (0)
DATE : 11/9/2004

ENTER CODE OR NAME OF THE CD TO BE ISSSUED


OR
PRESS ENTER FOR CD'S CATALOG _

32
CD ISSUED MENU

33
Exit (0)
DATE : 11/9/2004

CD NAME: DHOOM

ENTER CUSTOMERS CODE


OR
PRESS ENTER FOR CUSTOMERS CATALOG 1

CD ISSUED TO JYOTI

DATE OF RETURN : 26/9/2004

RETURN A CD MENU

34
EXIT (0)
DATE : 11/9/2004

ENTER CODE NO. OF THE CUSTOMER


OR
PRESS <ENTER> FOR CUSTOMERS CATALOG_

35
CD RETURNED MENU

EXIT (0)
DATE : 11/9/2004

CD NAME : DHOOM
CUSTOMER: JYOTI

CD RETURNED!!

36
CD’S CATALOG MENU

LIST OF CD's
____________________________________________________________________________

CODE CD NAME COPYRIGHT PRICE COPIES


____________________________________________________________________________

1 DHOOM HMV 100 5


STATUS: 5 COPIES AVAILABLE

2 FIDA SONY 150 8


STATUS: 8 COPIES AVAILABLE

3 KAHO NAA PYAAR HAI HMV 100 4


STATUS: 4 COPIES AVAILABLE

PRESS ANY KEY TO CONT...

37
CUSTOMERS CATALOG MENU

LIST OF CUSTOMERS
______________________________________________________________________________

CODE CDCODE NAME PHONE ADDRESS


______________________________________________________________________________

1 0 JYOTI 23642496 SHASTRI NAGAR


CD: -
2 0 SMARTH 23655043 B-150,SUBHADRA COLONY
CD: -
3 0 RAHUL 23651428 SHASTRI NAGAR
CD: -

PRESS ANY KEY TO CONT...

38
EDIT RECORD MENU

_____________________________________________________________________

EDIT MENU
_____________________________________________________________________

1. EDIT CD RECORDS
2. EDIT CUSTOMER RECORDS
0. EXIT

_____________________________________________________________________

PLEASE ENTER A SUITABLE CHOICE :

39
EDIT CD RECORD MENU

_____________________________________________________________________

EDIT CD RECORD
_____________________________________________________________________

1. MODIFY A RECORD
2. DELETE A RECORD
0. EXIT

_____________________________________________________________________

ENTER A SUITABLE CHOICE :

40
MODIFY CD RECORD MENU

EXIT (0)

CD CODE #: 1

CD NAME : DHOOM
COPYRIGHT : HMV
PRICE : Rs.100
COPIES :5
COPIES AT PRESENT : 5

DO YOU WANT TO MODIFY THIS RECORD ?(Y/N) : Y

CD NAME :
COPYRIGHT :
PRICE : Rs.

ENTER NEW NAME OF THE CD OR <ENTER> FOR NO CHANGE

41
DELETE CD RECORD MENU
EXIT (0)

CD CODE #: 1

CD NAME : DHOOM
COPYRIGHT : HMV
PRICE : Rs.100
COPIES :5
COPIES AT PRESENT : 5

WANT TO DELETE THIS RECORD ?(Y/N) :

42
EDIT CUSTOMERS RECORD MENU

______________________________________________________________________

EDIT CUSTOMER RECORD


______________________________________________________________________

1. MODIFY SPECIFIC RECORD


2. DELETE SPECIFIC RECORD
0. EXIT

______________________________________________________________________

ENTER A SUITABLE CHOICE :

43
MODIFY CUSTOMERS RECORD MENU

EXIT (0)

CUSTOMER CODE : 1
_____________________________________________________________________

NAME : JYOTI
PHONE : 23642496
ADDRESS : SHASTRI NAGAR

DO YOU WANT TO MODIFY THIS RECORD ?(Y/N) Y

NAME :
PHONE :
ADDRESS :

ENTER NEW NAME OF THE CUSTOMER OR <ENTER> FOR NO CHANGE

44
DELETE CUSTOMERS RECORD MENU

EXIT (0)

CUSTOMER CODE : 2
___________________________________________________________________

NAME : SMARTH
PHONE : 23655043
ADDRESS : B-150,SUBHADRA COLONY

WANT TO DELETE THIS RECORD ?(Y/N) Y

RECORD MODIFIED!!

45
PRINT REPORTS
CD’S CATALOG MENU

LIST OF CD's
____________________________________________________________________________

CODE CD NAME COPYRIGHT PRICE COPIES


____________________________________________________________________________

1 DHOOM HMV 100 5


STATUS: 5 COPIES AVAILABLE

2 FIDA SONY 150 8


STATUS: 8 COPIES AVAILABLE

3 KAHO NAA PYAAR HAI HMV 100 4


STATUS: 4 COPIES AVAILABLE

PRESS ANY KEY TO CONT...

46
CUSTOMERS CATALOG MENU

LIST OF CUSTOMERS
___________________________________________________________________________

CODE CDCODE NAME PHONE ADDRESS


___________________________________________________________________________

1 0 JYOTI 23642496 SHASTRI NAGAR


CD: -
2 0 SMARTH 23655043 B-150,SUBHADRA COLONY
CD: -
3 0 RAHUL 23651428 SHASTRI NAGAR
CD: -

PRESS ANY KEY TO CONT...

47
TEST SCREENS
SCREEN GENERATED IF WRONG CD CODE IS ENTERD

EXIT (0)
DATE : 11/9/2004

ENTER CODE OR NAME OF THE CD TO BE ISSSUED


OR
PRESS ENTER FOR CD'S CATALOG 5

NO SUCH RECORDS
PRESS <ESC> TO EXIT OR ANY OTHER KEY TO CONT...

48
SREEN GENERATED WHEN WRONG CUSTOMER CODE IS
ENTERED

Exit (0)
DATE : 11/9/2004

CD NAME: DHOOM

ENTER CUSTOMERS CODE


OR
PRESS ENTER FOR CUSTOMERS CATALOG 6

NO SUCH RECORDS
PRESS <ESC> TO EXIT OR ANY OTHER KEY TO CONT...

49
50
SCREEN GENERATED WHEN PRICE IS ENTERED IN ALPHABETS

EXIT (0)

ADDITION OF THE CD's


___________________________________________________________________
CODE NO. 4

CD NAME : MURDER
COPYRIGHT:HMV
PRICE : Rs.DDD

COPIES :

PLEASE ENTER CORRECTLY

51
SCREEN GENERATED WHEN COPIES IS ENTERED IN
APLPHABETS

EXIT (0)

ADDITION OF THE CD's


___________________________________________________________________
CODE NO. 4

CD NAME :MURDER
COPYRIGHT:HMV
PRICE : Rs.200

COPIES :D

PLEASE ENTER CORRECTLY

52
SCREEN GENERATED WHEN CUSTOMER’S NAME IS ENTERED
IN NUMERICS

EXIT (0)

ADDITION OF THE CUSTOMERS

_________________________________________________________________________

CUSTOMER CODE : 1
_________________________________________________________________________

NAME : 123

PHONE :

ADDRESS :

ENTER CORRECTLY (RANGE 1...25 AND NO DIGITS)

53
SCREEN GENERATED WHEN TELEPHONE NO. IS ENTERED IN
ALPHABETS

EXIT (0)

ADDITION OF THE CUSTOMERS

_____________________________________________________________________

CUSTOMER CODE : 1
_____________________________________________________________________

NAME : SMARTH

PHONE : ASDF

ADDRESS :

ENTER PHONE NO. OR <ENTER> FOR NONE (ONLY DIGITS PLZ!)

54
SCREEN GENERATED WHEN ADDRESS IS NOT ENTERED

EXIT (0)

ADDITION OF THE CUSTOMERS

___________________________________________________________________

CUSTOMER CODE : 1
___________________________________________________________________

NAME : SMARTH

PHONE :

ADDRESS :

ENTER AGAIN : MAXIMUM 100 ALPHABETS

55
SCREEN GENERATED WHEN CUSTOMER IS HAVING NO CD AND
HIS CODE IS ENTERED TO RETURN A CD

EXIT (0)
DATE : 11/9/2004

ENTER CODE NO. OF THE CUSTOMER


OR
PRESS <ENTER> FOR CUSTOMERS CATALOG 1

CUSTOMER HAVE NO CD TO RETURN


PRESS <ESC> TO EXIT OR ANY OTHER KEY TO CONT...

56
SCREEN GENERATED WHEN PRICE IS ENTERED IN ALPHABETS
DURING MODIFICATION
EXIT (0)

CD CODE #: 1

CD NAME : DHOOM
COPYRIGHT : HMV
PRICE : Rs.100
COPIES :5
COPIES AT PRESENT : 3

DO YOU WANT TO MODIFY THIS RECORD ?(Y/N) : Y

CD NAME : DHOOM
COPYRIGHT : SONY
PRICE : Rs. ASD

PLEASE ENTER CORRECTLY

57
SCREEN GENERATED WHEN A CODE IS ENTERED FOR
DELETING A CD RECORD WHICH IS NOT PRESENT

EXIT (0)

ENTER CODE NO. OR NAME OF THE CD TO BE DELETED


OR
PRESS <ENTER> FOR CD'S CATALOG 6

NO SUCH RECORDS
PRESS <ESC> TO EXIT OR ANY OTHER KEY TO CONT...

58
CHAPTER 7
CODING

//**********************************************************
// MOVIES PLANET
//**********************************************************

//**********************************************************
// INCLUDED HEADER FILES
//**********************************************************

#include <iostream.h>
#include <fstream.h>
#include <process.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <dos.h>

//**********************************************************
// THIS CLASS CONTROL ALL THE FUNCTIONS IN THE MENU
//**********************************************************

class MENU
{
public :
void main_menu(void) ;
void introduction(void) ;
private :
void edit_menu(void) ;
void edit_cd(void) ;
void edit_member(void) ;
};

//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO CD's
//**********************************************************

class CD
59
{
public :
int cdcode, copies ;
void list(void) ;
char *cdname(int) ;
protected :
void add_new_cd(int, char tname[33], char tcopyright[26],
float, int, int) ;
void update_copies(int, int, int) ;
void modify(int, char[], char[], float) ;
void deletion(void) ;
int cd_found(int) ;
int cdname_found(char []) ;
int recordno(int) ;
int available(int) ;
char *year(int) ;
float cdprice(int) ;
int no_of_copies(int) ;
int cdcodeof(char[]) ;
void display(int) ;
int reccount(void) ;
void delete_rec(int) ;
private :

char name[33], copyright[26] ;


float price ;
int avail ;

};

//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO CUSTOMERS
//**********************************************************

class CUSTOMER
{
public :
void list(void) ;
int cdcode;
CUSTOMER(){cdcode=0;}
protected :
void add_mem(int, int, char [], char [], char[], int, int, int) ;
void modify(int, char[], char[], char[]) ;
void deletion(void) ;
int member_found(int) ;
60
void update_cd(int, int, int, int, int) ;
char *membername(int) ;
char *memberphone(int) ;
char *memberaddress(int) ;
int recordno(int) ;
int lastcode(void) ;
int issued(int) ;
int fine(int) ;
void display(int) ;
void delete_rec(int) ;
private :
int memcode ;
char name[26], phone[10], address[50] ;
int dd, mm, yy ; // DATE OF RETURNING THE CD //
};

//**********************************************************
// THIS IS DERIVED FROM CLASS CD & CUSTOMER AND CONTAINS
// FUNCTIONS FOR WORKING (ISSUE,RETURN,ETC).
//**********************************************************

class WORKING : public CD, public CUSTOMER


{
public :
void issuecd(void) ;
void returncd(void) ;
void add_cd(void) ;
void add_member(void) ;
void modify_cd(void) ;
void modify_member(void) ;
void delete_cd(void) ;
void delete_member(void) ;
};

//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED DATE & FINE
//**********************************************************

class DATE
{
public :
void extend_date(int,int,int,int) ;
int diff(int, int, int, int, int, int) ;
int day, mon, year ;
61
};

//**********************************************************
// FUNCTION TO EXTEND GIVEN DATE BY 15 DAYS
//**********************************************************

void DATE :: extend_date(int d1, int m1, int y1, int days)
{
static int month[] = {31,29,31,30,31,30,31,31,30,31,30,31} ;
for (int i=1; i<=days; i++)
{
d1++ ;
if ((d1 > month[m1-1]) || (y1%4 != 0 && m1 == 2 && d1 >
28))
{
d1 = 1 ;
m1++ ;
}
if (m1 > 12)
{
m1 = 1 ;
y1++ ;
}
}
day = d1 ;
mon = m1 ;
year = y1 ;
}

//**********************************************************
// THIS FUNCTION RETURN THE DIFFERENCE BETWEEN TWO GIVEN
// DATES
//**********************************************************

int DATE :: diff(int d1, int m1, int y1, int d2, int m2, int y2)
{
int days = 0 ;
if ((y2<y1) || (y2==y1 && m2<m1) || (y2==y1 && m2==m1
&& d2<d1))
return days ;
static int month[] = {31,29,31,30,31,30,31,31,30,31,30,31} ;
while (d1 != d2 || m1 != m2 || y1 != y2)
{
62
days++ ;
d1++ ;
if ((d1 > month[m1-1]) || (y1%4 != 0 && m1 == 2 && d1 >
28))
{
d1 = 1 ;
m1++ ;
}
if (m1 > 12)
{
m1 = 1 ;
y1++ ;
}
}
return days ;
}

//**********************************************************
// FUNCTION TO DISPLAY MAIN MENU & CONTROL ALL THE FUNCTION
// IN THE MAIN MENU.
//**********************************************************

void MENU :: main_menu(void)


{

char ch ;
while (1)
{
clrscr() ;
gotoxy(1,4);
cout
<<"____________________________________________________________________
____________" ;
gotoxy(29,6) ;
cout<<"M O V I E S P L A N E T" ;
gotoxy(1,7) ;
cout
<<"____________________________________________________________________
____________" ;
gotoxy(30,10) ;
cout <<"1. INTRODUCTION" ;
gotoxy(30,11) ;
cout <<"2. ADD CD TO COLLECTION" ;
gotoxy(30,12) ;
cout <<"3. ADD A CUSTOMER" ;
63
gotoxy(30,13) ;
cout <<"4. ISSUE A CD" ;
gotoxy(30,14) ;
cout <<"5. RETURN CD" ;
gotoxy(30,15) ;
cout <<"6. CDs CATALOG " ;
gotoxy(30,16) ;
cout <<"7. CUSTOMERS CATALOG" ;
gotoxy(30,17) ;
cout <<"8. EDIT RECORDS" ;
gotoxy(30,18) ;
cout <<"0. EXIT" ;
gotoxy(1,20) ;
cout
<<"____________________________________________________________________
____________" ;
gotoxy(30,22);
cout <<"ENTER A SUITABLE CHOICE" ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch == '1')
introduction() ;
else
if (ch == '2')
{
WORKING W ;
W.add_cd() ;
}
else
if (ch == '3')
{
WORKING W ;
W.add_member() ;
}
else
if (ch == '4')
{
WORKING W ;
W.issuecd() ;
}
else
if (ch == '5')
{
WORKING W ;
64
W.returncd() ;
}
else
if (ch == '6')
{
CD B ;
B.list() ;
}
else
if (ch == '7')
{
CUSTOMER M ;
M.list() ;
}
else
if (ch == '8')
edit_menu() ;
else
if (ch == '0')
break ;
}
}

//**********************************************************
// FUNCTION TO DISPLAY EDIT MENU
//**********************************************************

void MENU :: edit_menu(void)


{

char ch ;
while (1)
{
clrscr() ;
gotoxy(1,7);
cout
<<"____________________________________________________________________
____________" ;
gotoxy(32,9) ;
cout <<"E D I T M E N U";
gotoxy(1,10) ;
cout
<<"____________________________________________________________________
____________" ;

65
gotoxy(32,13) ;
cout <<"1. EDIT CD RECORDS" ;
gotoxy(32,14) ;
cout <<"2. EDIT CUSTOMER RECORDS";
gotoxy(32,15) ;
cout <<"0. EXIT" ;
gotoxy(1,17) ;
cout
<<"____________________________________________________________________
____________" ;
gotoxy(31,20);
cout <<"PLEASE ENTER A SUITABLE CHOICE : " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch =='1')
edit_cd() ;
else
if (ch == '2')
edit_member() ;
else
if (ch == '0')
break ;
}
}

//**********************************************************
// FUNCTION TO DISPLAY EDIT MENU FOR CD & CONTROL
// ALL THE FUNCTION IN THE EDIT MENU.
//**********************************************************

void MENU :: edit_cd(void)


{

char ch ;
while (1)
{
clrscr() ;
gotoxy(1,8) ;
cout
<<"____________________________________________________________________
____________" ;
gotoxy(31,9) ;
cout <<"E D I T C D R E C O R D";
66
gotoxy(1,10) ;
cout
<<"____________________________________________________________________
____________" ;
gotoxy(34,13) ;
cout <<"1. MODIFY A RECORD" ;
gotoxy(34,14) ;
cout <<"2. DELETE A RECORD" ;
gotoxy(34,15) ;
cout <<"0. EXIT" ;
gotoxy(1,17) ;
cout
<<"____________________________________________________________________
____________" ;
gotoxy(31,20) ;
cout <<"ENTER A SUITABLE CHOICE : " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch == '1')
{
WORKING W ;
W.modify_cd() ;
}
else
if (ch == '2')
{
WORKING W ;
W.delete_cd() ;
}
else
if (ch == '0')
break ;
}
}

//**********************************************************
// FUNCTION TO DISPLAY EDIT MENU FOR CUSTOMERS & CONTROL
// ALL THE FUNCTION IN THE EDIT MENU.
//**********************************************************

void MENU :: edit_member(void)


{
char ch ;
67
while (1)
{
clrscr() ;
gotoxy(1,7);
cout
<<"_____________________________________________________
___________________________" ;
gotoxy(29,9) ;
cout <<"E D I T C U S T O M E R R E C O R D";
gotoxy(1,10) ;
cout
<<"_____________________________________________________
___________________________" ;
gotoxy(34,13) ;
cout <<"1. MODIFY SPECIFIC RECORD " ;
gotoxy(34,14) ;
cout <<"2. DELETE SPECIFIC RECORD" ;
gotoxy(34,15) ;
cout <<"0. EXIT" ;
gotoxy(1,17) ;
cout
<<"_____________________________________________________
___________________________" ;
gotoxy(34,19);
cout <<"ENTER A SUITABLE CHOICE : " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch == '1')
{
WORKING W ;
W.modify_member() ;
}
else
if (ch == '2')
{
WORKING W ;
W.delete_member() ;
}
else
if (ch == '0')
break ;
}
}

68
//**********************************************************
// FUNCTION TO DISPLAY THE INTRODUCTION FOR THE PROJECT.
//**********************************************************

void MENU :: introduction(void)


{
clrscr() ;
gotoxy(1,3);
cout
<<"_____________________________________________________
___________________________" ;
gotoxy(13,5) ;
cout <<"W E L C O M E T O T H E M O V I E P L A N E
T" ;
gotoxy(1,6);
cout
<<"_____________________________________________________
___________________________" ;
gotoxy(28,8) ;
cprintf(" MADE BY:- SMARTH VIP ") ;

gotoxy(5,10) ;
cout <<"* THIS PROJECT WILL FACILITATE KEEPING
RECORDS OF CD'S AND CUSTOMERS";
gotoxy(16,11);
cout<<" IN A SYSTEMATIC AND EASILY ACCESSIBLE
MANNER " ;
gotoxy(5,13);
cout<<"* CHARGES FINE AFTER SKIPPING THE DATE OF
RETURN @ OF Rs.2 PER DAY";
gotoxy(5,15);
cout<<"* LISTS CDs AND CUSTOMERS RECORDS";
gotoxy(24,24) ;
cprintf("PRESS ANY KEY TO RUN THE PROJECT") ;
textcolor(LIGHTGRAY) ;
getch() ;
}

//**********************************************************
// THIS FUNCTION RETURN 0 IF GIVEN CD CODE NOT FOUND
//**********************************************************

int CD :: cd_found(int tcode)


{
69
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) this, sizeof(CD)))
{
if (cdcode == tcode)
{
found = 1 ;
break ;
}
}
file.close() ;
return found ;
}

//**********************************************************
// THIS FUNCTION RETURN 0 IF GIVEN CD NAME NOT FOUND
//**********************************************************

int CD :: cdname_found(char t1code[33])


{
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) this, sizeof(CD)))
{
if (!strcmp(name,t1code))
{
found = 1 ;
break ;
}
}
file.close() ;
return found ;
}

//**********************************************************
// THIS FUNCTION RETURN RECORD NO. FOR THE CD CODE
//**********************************************************

int CD :: recordno(int tcode)


{
70
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(CD)))
{
count++ ;
if (cdcode == tcode)
break ;
}
file.close() ;
return count ;
}

//**********************************************************
// THIS FUNCTION RETURNS THE AVAILABLE COPIES FOR THE GIVEN
// CD CODE.
//**********************************************************

int CD :: available(int tcode)


{
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int tavail=0 ;
while (file.read((char *) this, sizeof(CD)))
{
if (cdcode == tcode)
{
tavail = avail ;
break ;
}
}
file.close() ;
return tavail ;
}

//**********************************************************
// THIS FUNCTION RETURNS THE NO. OF COPIES FOR THE GIVEN
// CD CODE.
//**********************************************************

int CD :: no_of_copies(int tcode)


{
71
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int tcopies=0 ;
while (file.read((char *) this, sizeof(CD)))
{
if (cdcode == tcode)
{
tcopies = copies ;
break ;
}
}
file.close() ;
return tcopies ;
}

//**********************************************************
// THIS FUNCTION RETURNS THE CD NAME OF THE GIVEN CD
// CODE.
//**********************************************************

char *CD :: cdname(int tcode)


{
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
char tname[33] ;
while (file.read((char *) this, sizeof(CD)))
{
if (cdcode == tcode)
{
strcpy(tname,name) ;
break ;
}
}
file.close() ;
return tname ;
}

//**********************************************************
// THIS FUNCTION RETURNS THE COPYRIGHT NAME OF THE GIVEN CD
// CODE.
//**********************************************************

72
char *CD :: year(int tcode)
{
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
char tcopyright[26] ;
while (file.read((char *) this, sizeof(CD)))
{
if (cdcode == tcode)
{
strcpy(tcopyright,copyright) ;
break ;
}
}
file.close() ;
return tcopyright ;
}

//**********************************************************
// THIS FUNCTION RETURNS THE CD PRICE OF THE GIVEN CD
// CODE.
//**********************************************************

float CD :: cdprice(int tcode)


{
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
float tprice=0.0 ;
while (file.read((char *) this, sizeof(CD)))
{
if (cdcode == tcode)
{
tprice = price ;
break ;
}
}
file.close() ;
return tprice ;
}

//**********************************************************
// THIS FUNCTION RETURNS THE CD CODE OF THE GIVEN CD
// NAME.
73
//**********************************************************

int CD :: cdcodeof(char t1code[33])


{
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int tcode=0 ;
while (file.read((char *) this, sizeof(CD)))
{
if (!strcmp(name,t1code))
{
tcode = cdcode ;
break ;
}
}
file.close() ;
return tcode ;
}

//**********************************************************
// THIS FUNCTION RETURNS THE NO. OF THE RECORDS IN THE CD
// FILE.
//**********************************************************

int CD :: reccount(void)
{
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(CD)))
count++ ;
file.close() ;
return count ;
}

//**********************************************************
// THIS FUNCTION DELETES THE RECORD OF THE GIVEN CD CODE.
//**********************************************************

void CD :: delete_rec(int tcode)


{
fstream file ;
74
file.open("CD.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(CD)) ;
if ( file.eof() )
break ;
if ( cdcode != tcode )
temp.write((char *) this, sizeof(CD)) ;
}
file.close() ;
temp.close() ;
file.open("CD.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(CD)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(CD)) ;
}
file.close() ;
temp.close() ;
}

//**********************************************************
// THIS FUNCTION ADD THE RECORD IN THE CD FILE
//**********************************************************

void CD :: add_new_cd(int tcode,char tname[33], char tcopyright[26], float tprice, int


tcopies, int tavail)
{
fstream file ;
file.open("CD.DAT", ios::app) ;
cdcode = tcode ;
strcpy(name,tname) ;
strcpy(copyright,tcopyright) ;
price = tprice ;
copies = tcopies ;
avail = tavail ;
file.write((char *) this, sizeof(CD)) ;
file.close() ;
75
}

//**********************************************************
// THIS FUNCTION UPDATE THE RECORD IN THE CD FILE FOR THE
// GIVEN CD CODE
//**********************************************************

void CD :: update_copies(int tcode, int tcopies, int tavail)


{
int recno ;
recno = recordno(tcode) ;
fstream file ;
file.open("CD.DAT", ios::out | ios::ate) ;
copies = tcopies ;
avail = tavail ;
int location ;
location = (recno-1) * sizeof(CD) ;
file.seekp(location) ;
file.write((char *) this, sizeof(CD)) ;
file.close() ;
}

//**********************************************************
// THIS FUNCTION MODIFY THE RECORD IN THE CD FILE FOR THE
// GIVEN CD CODE
//**********************************************************

void CD :: modify(int tcode, char tname[33], char tcopyright[26], float tprice)


{
int recno ;
recno = recordno(tcode) ;
fstream file ;
file.open("CD.DAT", ios::out | ios::ate) ;
strcpy(name,tname) ;
strcpy(copyright,tcopyright) ;
price = tprice ;
int location ;
location = (recno-1) * sizeof(CD) ;
file.seekp(location) ;
file.write((char *) this, sizeof(CD)) ;
file.close() ;
}

76
//**********************************************************
// THIS FUNCTION DISPLAY THE RECORD FROM THE CD FILE
// FOR THE GIVEN CD CODE
//**********************************************************

void CD :: display(int tcode)


{
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(CD)))
{
if (cdcode == tcode)
{
gotoxy(35,5) ;
cout <<"CD CODE #: " <<cdcode ;
gotoxy(5,7) ;
cout <<"CD NAME : " <<name ;
gotoxy(5,8) ;
cout <<"COPYRIGHT : " <<copyright ;
gotoxy(5,9) ;
cout <<"PRICE : Rs." <<price ;
gotoxy(5,10) ;
cout <<"COPIES : " <<copies ;
gotoxy(5,11) ;
cout <<"COPIES AT PRESENT : " <<avail ;
break ;
}
}
file.close() ;
}

//**********************************************************
// THIS FUNCTION DISPLAY THE LIST OF CD's.
//**********************************************************

void CD :: list(void)
{
clrscr() ;
int row = 11 , found=0, flag=0 ;
char ch ;
gotoxy(33,4) ;
cout <<"LIST OF CD's" ;
gotoxy(1,5) ;

77
cout
<<"____________________________________________________________________
____________" ;
gotoxy(2,7) ;
cout <<"CODE CD NAME COPYRIGHT
PRICE COPIES" ;
gotoxy(1,8) ;
cout
<<"____________________________________________________________________
____________" ;
fstream file ;
file.open("CD.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(CD)))
{
flag = 0 ;
delay(20) ;
found = 1 ;
gotoxy(2,row) ;
cout <<cdcode ;
gotoxy(7,row) ;
cout <<name ;
gotoxy(40,row) ;
cout <<copyright ;
gotoxy(66,row) ;
cout <<price ;
gotoxy(73,row) ;
cout <<copies ;
gotoxy(40,row+1) ;
cprintf("STATUS: ") ;
cprintf("%d COPIES AVAILABLE",avail) ;

if ( row == 22 )
{
flag = 1 ;
row = 6 ;
gotoxy(1,25) ;
cout <<"PRESS ANY KEY TO CONT.. OR <ESC> TO
EXIT" ;
ch = getch() ;
if (ch == 27)
break ;
clrscr() ;
gotoxy(33,2) ;
cout <<"LIST OF CD's" ;
gotoxy(1,3) ;
78
cout
<<"____________________________________________________________________
____________" ;
gotoxy(1,4) ;
cout <<"CODE CD NAME COPYRIGHT
PRICE COPIES" ;
gotoxy(1,5) ;
cout
<<"____________________________________________________________________
____________" ;

}
else
row = row + 2 ;
}
if (!found)
{
gotoxy(5,10) ;
cout <<"\7NO RECORDS" ;
}
if (!flag)
{
gotoxy(1,25) ;
cout <<"PRESS ANY KEY TO CONT..." ;
getche() ;
}
file.close () ;
}

//**********************************************************
// THIS FUNCTION RETURN 0 IF THE GIVEN CUSTOMER CODE NOT FOUND
//**********************************************************

int CUSTOMER :: member_found(int mcode)


{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) this, sizeof(CUSTOMER)))
{
if (memcode == mcode)
{
found = 1 ;
break ;
79
}
}
file.close() ;
return found ;
}

//**********************************************************
// THIS FUNCTION RETURN 0 IF THE CUSTOMER HAVE NOT ISSUED ANY
// CD.
//**********************************************************

int CUSTOMER :: issued(int mcode)


{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int missue=0 ;
while (file.read((char *) this, sizeof(CUSTOMER)))
{
if (memcode == mcode)
{
missue = cdcode ;
break ;
}
}
file.close() ;
return missue ;
}

//**********************************************************
// THIS FUNCTION CALCULATE AND RETURN FINE FOR THE GIVEN
// CUSTOMER CODE.
//**********************************************************

int CUSTOMER :: fine(int mcode)


{
DATE D ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
fstream file ;
80
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int days, t_fine ;
while (file.read((char *) this, sizeof(CUSTOMER)))
{
if (memcode == mcode)
{
days = D.diff(dd,mm,yy,d1,m1,y1) ;
t_fine = days * 2 ;
break ;
}
}
file.close() ;
return t_fine ;
}

//**********************************************************
// THIS FUNCTION RETURN THE LAST CODE OF THE CUSTOMER FILE.
//**********************************************************

int CUSTOMER :: lastcode(void)


{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int mcode=0 ;
while (file.read((char *) this, sizeof(CUSTOMER)))
mcode = memcode ;

file.close() ;
return mcode ;
}

//**********************************************************
// THIS FUNCTION RETURNS CUSTOMER NAME OF THE GIVEN CUSTOMER
// CODE.
//**********************************************************

char *CUSTOMER :: membername(int mcode)


{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
char mname[26] ;
81
while (file.read((char *) this, sizeof(CUSTOMER)))
{
if (memcode == mcode)
{
strcpy(mname,name) ;
break ;
}
}
file.close() ;
return mname ;
}

//**********************************************************
// THIS FUNCTION RETURNS CUSTOMER PHONE OF THE GIVEN CUSTOMER
// CODE.
//**********************************************************

char *CUSTOMER :: memberphone(int mcode)


{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
char mphone[10] ;
while (file.read((char *) this, sizeof(CUSTOMER)))
{
if (memcode == mcode)
{
strcpy(mphone,phone) ;
break ;
}
}
file.close() ;
return mphone ;
}

//**********************************************************
// THIS FUNCTION RETURNS CUSTOMER ADDRESS OF THE GIVEN
CUSTOMER
// CODE.
//**********************************************************

char *CUSTOMER :: memberaddress(int mcode)


{
fstream file ;
82
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
char maddress[33] ;
while (file.read((char *) this, sizeof(CUSTOMER)))
{
if (memcode == mcode)
{
strcpy(maddress,address) ;
break ;
}
}
file.close() ;
return maddress ;
}

//**********************************************************
// THIS FUNCTION RETURNS RECORD NO. OF THE GIVEN CUSTOMER
// CODE.
//**********************************************************

int CUSTOMER :: recordno(int mcode)


{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(CUSTOMER)))
{
count++ ;
if (memcode == mcode)
break ;
}
file.close() ;
return count ;
}

//**********************************************************
// THIS FUNCTION DELETE RECORD FOR THE GIVEN CUSTOMER CODE.
//**********************************************************

void CUSTOMER :: delete_rec(int mcode)


{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
83
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(CUSTOMER)) ;
if ( file.eof() )
break ;
if ( memcode != mcode )
temp.write((char *) this, sizeof(CUSTOMER)) ;
}
file.close() ;
temp.close() ;
file.open("CUSTOMER.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(CUSTOMER)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(CUSTOMER)) ;
}
file.close() ;
temp.close() ;
}

//**********************************************************
// THIS FUNCTION UPDATE RECORD FOR THE GIVEN CUSTOMER CODE.
//**********************************************************

void CUSTOMER :: update_cd(int mcode, int tcode, int d1, int m1, int y1)
{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(CUSTOMER)) ;
if ( file.eof() )
break ;
if ( memcode == mcode )
{
84
cdcode = tcode ;
dd = d1 ;
mm = m1 ;
yy = y1 ;
temp.write((char *) this, sizeof(CUSTOMER)) ;
}
else
temp.write((char *) this, sizeof(CUSTOMER)) ;
}
file.close() ;
temp.close() ;
file.open("CUSTOMER.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(CUSTOMER)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(CUSTOMER)) ;
}
file.close() ;
temp.close() ;
}

//**********************************************************
// THIS FUNCTION MODIFY RECORD FOR THE GIVEN CUSTOMER CODE.
//**********************************************************

void CUSTOMER :: modify(int mcode, char mname[26], char mphone[10], char


maddress[33])
{
int recno ;
recno = recordno(mcode) ;
fstream file ;
file.open("CUSTOMER.DAT", ios::out | ios::ate) ;
strcpy(name,mname) ;
strcpy(phone,mphone) ;
strcpy(address,maddress) ;
int location ;
location = (recno-1) * sizeof(CUSTOMER) ;
file.seekp(location) ;
file.write((char *) this, sizeof(CUSTOMER)) ;
file.close() ;
}
85
//**********************************************************
// THIS FUNCTION ADD RECORD IN THE FILE FOR THE GIVEN
// CUSTOMER CODE.
//**********************************************************

void CUSTOMER :: add_mem(int mcode, int bcode, char mname[26], char


maddress[33], char mphone[10], int d1, int m1, int y1)
{
fstream file ;
file.open("CUSTOMER.DAT", ios::app) ;
memcode = mcode ;
cdcode = bcode ;
strcpy(name,mname) ;
strcpy(address,maddress) ;
strcpy(phone,mphone) ;
dd = d1 ;
mm = m1 ;
yy = y1 ;
file.write((char *) this, sizeof(CUSTOMER)) ;
file.close() ;
}

//**********************************************************
// THIS FUNCTION DISPLAY THE RECORD FOR THE GIVEN CUSTOMER
// CODE.
//**********************************************************

void CUSTOMER :: display(int mcode)


{
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(CUSTOMER)))
{
if (memcode == mcode)
{
gotoxy(33,3) ;
cout <<"CUSTOMER CODE : " <<mcode ;
gotoxy(1,4) ;
cout
<<"____________________________________________________________________
____________" ;
gotoxy(30,6) ;
86
cout <<"NAME : " <<name ;
gotoxy(30,7) ;
cout <<"PHONE : " <<phone ;
gotoxy(30,8) ;
cout <<"ADDRESS : " <<address ;
break ;
}
}
file.close() ;
}

//**********************************************************
// THIS FUNCTION DISPLAY THE LIST OF THE CUSTOMERS
//**********************************************************

void CUSTOMER :: list(void)


{
clrscr() ;
CD B ;
int row = 6 , found=0, flag=0 ;
char ch ;
gotoxy(32,2) ;
cout <<"LIST OF CUSTOMERS" ;
gotoxy(1,3) ;
cout
<<"____________________________________________________________________
____________" ;
gotoxy(2,4) ;
cout <<"CODE CDCODE NAME PHONE
ADDRESS " ;
gotoxy(1,5) ;
cout
<<"____________________________________________________________________
____________" ;
fstream file ;
file.open("CUSTOMER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(CUSTOMER)))
{
flag = 0 ;
delay(20) ;
found = 1 ;
gotoxy(2,row) ;
cout <<memcode ;
gotoxy(10,row) ;
87
cout <<cdcode ;
gotoxy(20,row) ;
cout <<name ;
gotoxy(37,row) ;
cout <<phone ;
gotoxy(50,row);
cout<<address;
gotoxy(7,row+1) ;
if (cdcode == 0)
cprintf("CD: - ") ;
else
{
cprintf("CD: %s",B.cdname(cdcode)) ;
gotoxy(50,row+1) ;
cprintf("RETURN ON: ") ;
cprintf("%d/%d/%d",dd,mm,yy) ;
}

if ( row == 22 )
{
flag = 1 ;
row = 6 ;
gotoxy(1,25) ;
cout <<"PRESS <ESC> TO EXIT OR ANY OTHER KEY
TO CONT..." ;
ch = getch() ;
if (ch == 27)
break ;
clrscr() ;
gotoxy(32,2) ;
cout <<"LIST OF CUSTOMERS" ;
gotoxy(1,3) ;
cout
<<"_______________________________________________________________" ;
gotoxy(1,4) ;
cout <<"CODE NAME PHONE" ;
gotoxy(1,5) ;
cout
<<"_______________________________________________________________" ;
}
else
row = row + 2 ;
}
if (!found)
{
gotoxy(15,20) ;
88
cout <<"\7 NO RECORDS TO DISPLAY" ;
}
if (!flag)
{
gotoxy(1,25) ;
cout <<"PRESS ANY KEY TO CONT..." ;
getche() ;
}
file.close () ;
}

//**********************************************************
// THIS FUNCTION GIVES DATA TO ADD RECORD IN THE CD FILE.
//**********************************************************

void WORKING :: add_cd(void)


{

if (!reccount()) // CUSTOMER FUNCTION OF CD


{
add_new_cd(0,"null","null",0.0,0,0) ;
CD::delete_rec(0) ;
}
char ch ;
int tcode, tcopies, tavail ;
char tname[33], tcopyright[26] ;
float tprice=0.0 ;
do
{
int found=0, valid=0 ;
int tc ;
float t2=0.0 ;
char t[10], t1[10] ;
clrscr() ;
gotoxy(29,3) ;
cout <<"ADDITION OF THE CD's" ;
gotoxy(1,4) ;
cout
<<"____________________________________________________________________
____________" ;
gotoxy(72,1) ;
89
cout <<"EXIT (0)" ;
gotoxy(5,25) ;
cout <<"ENTER CODE NO." ;
gotoxy(33,5) ;
cout <<"CODE NO. " ;
gets(t) ;
tc = atoi(t) ;
tcode = tc ;
if (tcode == 0)
return ;
if (cd_found(tcode))
{
found = 1 ;
gotoxy(39,8) ;
cout <<cdname(tcode) ;
gotoxy(39,9) ;
cout <<year(tcode) ;
gotoxy(39,10) ;
cout <<cdprice(tcode) ;
}
gotoxy(28,8) ;
cout <<"CD NAME : " ;
gotoxy(28,9) ;
cout <<"COPYRIGHT: " ;
gotoxy(28,10) ;
cout <<"PRICE : Rs." ;
gotoxy(28,12) ;
cout <<"COPIES : " ;
valid = 0 ;
while (!valid && !found)
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"NAME OF THE CD" ;
gotoxy(38,8) ; clreol() ;
gets(tname) ;
strupr(tname) ;
if (tname[0] == '0')
return ;
if (strlen(tname) < 1 || strlen(tname) > 32)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY (MAXIMUM 32
ALPHABETS)" ;
getch() ;
90
}
}
valid = 0 ;
while (!valid && !found)
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER THE COPYRIGHTERS NAME FOR
THE CD" ;
gotoxy(38,9) ; clreol() ;
gets(tcopyright) ;
strupr(tcopyright) ;
if (tcopyright[0] == '0')
return ;
if (strlen(tcopyright) < 1 || strlen(tcopyright) > 25)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY :- 1..25" ;
getch() ;
}
}
valid = 0 ;
while (!valid && !found)
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER PRICE OF THE CD" ;
gotoxy(42,10) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tprice = t2 ;
if (t1[0] == '0')
return ;
if (tprice < 1 || tprice > 9999)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7PLEASE ENTER CORRECTLY" ;
getch() ;
}
}
valid = 0 ;
while (!valid)
{
valid = 1 ;
91
gotoxy(5,25) ; clreol() ;
cout <<"ENTER NO. OF COPIES TO ADD" ;
gotoxy(38,12) ; clreol() ;
gets(t) ;
tc = atoi(t) ;
tcopies = tc ;
if (t[0] == '0')
return ;
if (tcopies < 1 || tcopies > 50)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7PLEASE ENTER CORRECTLY" ;
getch() ;
}
}
tavail = available(tcode) + tcopies ;
tcopies = no_of_copies(tcode) + tcopies ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(30,15) ; clreol() ;
cout <<"SAVE THIS RECORD ?(Y/N) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;

if (ch == 'Y')
{
if (found)
update_copies(tcode,tcopies,tavail) ;
else

add_new_cd(tcode,tname,tcopyright,tprice,tcopies,tavail) ;
}
do
{
gotoxy(30,17) ; clreol() ;
cout <<"ADD MORE CD'S ?(Y/N) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
} while (ch == 'Y') ;
}

92
//**********************************************************
// THIS FUNCTION GIVES DATA TO ADD RECORD IN THE CUSTOMER FILE
//**********************************************************

void WORKING :: add_member(void)


{
char ch ;
int mcode, bcode ;
char mname[26], mphone[10], maddress[33] ;
int d1, m1, y1 ;
mcode = lastcode() ;
if (mcode == 0)
{
add_mem(mcode,0,"null","null","null",0,0,0) ;
CUSTOMER::delete_rec(mcode) ;
}
mcode++ ;
do
{
int valid=0 ;
clrscr() ;
gotoxy(28,3) ;
cout <<"ADDITION OF THE CUSTOMERS" ;
gotoxy(1,5) ;
cout
<<"____________________________________________________________________
____________" ;
gotoxy(35,1) ;
cout <<"EXIT (0)" ;
gotoxy(30,7) ;
cout <<"CUSTOMER CODE : " <<mcode ;
gotoxy(1,8) ;
cout
<<"____________________________________________________________________
____________" ;
gotoxy(27,10) ;
cout <<"NAME : " ;
gotoxy(27,12) ;
cout <<"PHONE : " ;
gotoxy(27,14) ;
cout <<"ADDRESS : " ;
do
{
valid = 1 ; int i=0;
gotoxy(4,25) ; clreol() ;

93
cout <<" ENTER CUSTOMERS NAME (NO DIGITS
PLEASE!!)" ;
gotoxy(38,10) ; clreol() ;

gets(mname);
strupr(mname);
if(mname[0]=='0')
return;
int flag=0;
m1=strlen(mname);
for(i=0;i<m1;i++)
{
if(mname[i]<65||mname[i]>91)
{
if(mname[i]!=32)
flag=1;
}break;
}
if(flag)
{
valid=0;
gotoxy(5,25);
clreol();
cout<<"\7 ENTER CORRECTLY(RANGE 1...25)";
getch();
}//end of if
} while(! valid); //end of do while

do
{
valid = 1 ; int flag=0;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER PHONE NO. OR <ENTER> FOR NONE
(ONLY DIGITS PLZ!)" ;
gotoxy(38,12) ; clreol() ;
gets(mphone) ;

if (mphone[0] == '0')
return ;
for(int i=0;i<strlen(mphone);i++)
{
if((mphone[i]>='A' && mphone[i]<='Z')||
(mphone[i]>='a' && mphone[i]<='z'))
{
valid=0;
gotoxy(35,23);
94
break;
}
}

if ((strlen(mphone) < 7 && strlen(mphone) > 0) || (strlen(mphone) > 9))


{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7PLEASE ENTER CORRECTLY" ;
gotoxy(19,12);
}
} while (!valid) ;
if (strlen(mphone) == 0)
strcpy(mphone,"-") ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ADDRESS OF THE CUSTOMER " ;
gotoxy(38,14) ; clreol() ;
gets(maddress) ;
strupr(maddress) ;
if (maddress[0] == '0')
return ;
if (strlen(maddress) < 1 || strlen(maddress) > 49)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER AGAIN : MAXIMUM 100
ALPHABETS" ;
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(25,22) ; clreol() ;
cout <<"SAVE THIS RECORD? (Y/N) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'Y')
{
bcode = 0 ;
95
d1 = 0 ;
m1 = 0 ;
y1 = 0 ;

add_mem(mcode,bcode,mname,maddress,mphone,d1,m1,y1) ;
mcode++ ;
}
do
{
gotoxy(25,25) ; clreol() ;
cout <<"ADD NEW CUSTOMER ?(Y/N) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
} while (ch == 'Y') ;
}

//**********************************************************
// THIS FUNCTION ISSUES THE CD
//**********************************************************

void WORKING :: issuecd(void)


{
CD B ;
CUSTOMER M ;
DATE D ;
char t1code[33], ch ;
int t2code=0, tcode=0, mcode=0 ;
int valid,chet=2 ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(5,2) ;
cout <<"DATE : " <<d1 <<"/" <<m1 <<"/" <<y1 ;
96
gotoxy(72,1) ;
cout <<"EXIT (0)" ;
gotoxy(5,5) ;
cout <<"ENTER CODE OR NAME OF THE CD TO BE
ISSSUED" ;
gotoxy(5,6) ;
cout <<" OR ";
gotoxy(5,7) ;
cout <<"PRESS ENTER FOR CD'S CATALOG " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
B.list() ;
else
break ;
}
t2code = atoi(t1code) ;
tcode = t2code ;

if ((tcode == 0 && !cdname_found(t1code)) || (tcode != 0 && !


cd_found(tcode)))
{
valid = 0 ;
gotoxy(5,10) ;
cout <<"\7NO SUCH RECORDS" ;
gotoxy(5,11) ;
cout <<"PRESS <ESC> TO EXIT OR ANY OTHER KEY
TO CONT..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
if (tcode == 0)
tcode = cdcodeof(t1code) ;
if (!available(tcode))
{
gotoxy(5,10) ;
cout <<"\7SORRY! CD (" <<cdname(tcode) <<") IS NOT
AVAILABLE" ;
gotoxy(5,11) ;
cout <<"PLEASE CHOOSE ANOTHER CD" ;
gotoxy(5,12) ;
cout <<" REFER CD'S CATALOG" ;
getch() ;
97
return ;
}
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"Exit (0)" ;
gotoxy(5,2) ;
cout <<"DATE : " <<d1 <<"/" <<m1 <<"/" <<y1 ;
gotoxy(5,5) ;
cout <<"CD NAME: " <<cdname(tcode) ;
gotoxy(25,7) ;
cout <<" ENTER CUSTOMERS CODE" ;
gotoxy(25,8) ;
cout <<" OR ";
gotoxy(25,9) ;
cout <<"PRESS ENTER FOR CUSTOMERS CATALOG
";
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
M.list() ;
else
break ;
}
t2code = atoi(t1code) ;

mcode = t2code ;
if (issued(mcode)!= 0)
{
valid = 0 ;
gotoxy(5,10) ;
cout <<"\7CUSTOMER IS ALREADY HAVING A CD" ;
gotoxy(5,11) ;
cout <<"PRESS <ESC> TO EXIT OR ANY OTHER KEY
TO CONT..." ;
ch = getch() ;
if (ch == 27)
return ;
}
if (mcode == 0)

98
{
valid = 0 ;
gotoxy(5,25) ;
cout <<"\7PLEASE ENTER CORRECTLY!!" ;
getch() ;
}
if (!member_found(mcode) && valid)
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7NO SUCH RECORDS" ;
gotoxy(5,14) ;
cout <<"PRESS <ESC> TO EXIT OR ANY OTHER KEY
TO CONT..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
int tcopies, tavail ;

tcopies = no_of_copies(tcode) ; // member function of CD


tavail = available(tcode) - 1 ; // member function of CD
update_copies(tcode,tcopies,tavail) ; // member function of CD
D.extend_date(d1,m1,y1,15) ;
d1 = D.day ;
m1 = D.mon ;
y1 = D.year ;
update_cd(mcode,tcode,d1,m1,y1) ; // member function of
CUSTOMER
gotoxy(30,13) ;
cout <<"\7CD ISSUED TO " <<membername(mcode) ;
gotoxy(30,15) ;
cout <<"DATE OF RETURN : " <<d1 <<"/" <<m1 <<"/" <<y1 ;
getch() ;

//**********************************************************
// THIS FUNCTION RETURNS THE CD FOR THE CUSTOMER
//**********************************************************

void WORKING :: returncd(void)


99
{
CUSTOMER M ;
char t1code[5], ch ;
int t2code=0, mcode=0, valid ;
int d1, m1, y1 ;
struct date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"EXIT (0)" ;
gotoxy(5,2) ;
cout <<"DATE : " <<d1 <<"/" <<m1 <<"/" <<y1 ;
gotoxy(20,7) ;
cout <<" ENTER CODE NO. OF THE CUSTOMER" ;
gotoxy(20,8) ;
cout <<" OR ";
gotoxy(20,9) ;
cout <<" PRESS <ENTER> FOR CUSTOMERS
CATALOG " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
M.list() ;
else
break ;
}
t2code = atoi(t1code) ;
mcode = t2code ;
if (mcode == 0)
{
valid = 0 ;
gotoxy(5,25) ;
cout <<"\7 PLEASE ENTER CORRECTLY" ;
getch() ;
}
if (!member_found(mcode) && valid)
{
100
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7NO SUCH RECORD" ;
gotoxy(5,14) ;
cout <<"PRESS <ESC> TO EXIT OR ANY OTHER KEY
TO CONT..." ;
ch = getch() ;
if (ch == 27)
return ;
}
if (!issued(mcode) && valid)
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7 CUSTOMER HAVE NO CD TO RETURN" ;
gotoxy(5,14) ;
cout <<"PRESS <ESC> TO EXIT OR ANY OTHER KEY
TO CONT..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
int bcode, tcopies, tavail ;
bcode = issued(mcode) ;
gotoxy(5,13) ;
cout <<"CD CODE : " <<bcode ;
gotoxy(5,14) ;
cout <<"CD NAME : " <<cdname(bcode) ;
tcopies = no_of_copies(bcode) ;
tavail = available(bcode) + 1 ;
int f ;
f = fine(mcode) ;
if (f != 0)
{
gotoxy(20,16) ;
cout <<"PAY A FINE OF Rs." <<f ;
gotoxy(20,17) ;
cout <<"FOR DELAYING THE RETURN OF THE CD" ;
}
update_copies(bcode,tcopies,tavail) ;
update_cd(mcode,0,0,0,0) ;
gotoxy(33,19) ;
cout <<"\7CD RETURNED!!" ;
getch() ;
}
101
//**********************************************************
// THIS FUNCTION GIVES DATA TO MODIFY THE CD RECORD
//**********************************************************

void WORKING :: modify_cd(void)


{
CD B ;
char t1code[5], tname[33], tcopyright[26], *t1, ch ;
int t2code=0, tcode=0 ;
float t2=0.0, tprice=0.0 ;
int valid ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"EXIT(0)" ;
gotoxy(20,5) ;
cout <<"ENTER CODE OR NAME OF THE CD TO
MODIFY" ;
gotoxy(20,6) ;
cout <<" OR ";
gotoxy(20,7) ;
cout <<"PRESS ENTER TO SEE CD'S CATALOG " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
B.list() ;
else
break ;
}
t2code = atoi(t1code) ;
tcode = t2code ;
if ((tcode == 0 && !cdname_found(t1code)) || (tcode != 0 && !
cd_found(tcode)))
{
valid = 0 ;
gotoxy(5,10) ;
cout <<"\7NO SUCH RECORD" ;
gotoxy(5,11) ;

102
cout <<"PRESS <ESC> TO EXIT OR ANY OTHER KEY
TO CONT.." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
if (tcode == 0)
tcode = cdcodeof(t1code) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"EXIT (0)" ;
CD::display(tcode) ;
do
{
gotoxy(20,13) ; clreol() ;
cout <<"DO YOU WANT TO MODIFY THIS RECORD ?
(Y/N) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
gotoxy(5,16) ;
cout <<"CD NAME : " ;
gotoxy(5,17) ;
cout <<"COPYRIGHT : " ;
gotoxy(5,18) ;
cout <<"PRICE : Rs." ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER NEW NAME OF THE CD OR <ENTER>
FOR NO CHANGE" ;
gotoxy(19,16) ; clreol() ;
gets(tname) ;
strupr(tname) ;
if (tname[0] == '0')
return ;
if (strlen(tname) > 32)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
103
cout <<"\7PLEASE ENTER CORRECTLY :- 1..32)" ;
getch() ;
}
} while (!valid) ;
if (strlen(tname) == 0)
strcpy(tname,cdname(tcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER NEW COPYRIGHTERS NAME OR
<ENTER> FOR NO CHANGE" ;
gotoxy(19,17) ; clreol() ;
gets(tcopyright) ;
strupr(tcopyright) ;
if (tcopyright[0] == '0')
return ;
if (strlen(tcopyright) > 25)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7PLEASE ENTER CORRECTLY :-1..25)" ;
getch() ;
}
} while (!valid) ;
if (strlen(tcopyright) == 0)
strcpy(tcopyright,year(tcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER NEW PRICE OR <ENTER> FOR NO
CHANGE" ;
gotoxy(22,18) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tprice = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
if (tprice < 1 || tprice > 9999)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7PLEASE ENTER CORRECTLY" ;
104
getch() ;
}
} while (!valid) ;
if (strlen(t1) == 0)
tprice = cdprice(tcode) ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(30,20) ; clreol() ;
cout <<"SAVE THIS RECORD ? (Y/N) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
CD::modify(tcode,tname,tcopyright,tprice) ;
gotoxy(5,23) ;
cout <<"\7RECORD MODIFIED!!" ;
getch() ;
}

//**********************************************************
// THIS FUNCTION GIVES DATA TO MODIFY THE CUSTOMER RECORD
//**********************************************************

void WORKING :: modify_member(void)


{
CUSTOMER M ;
char m1code[10], mname[26], mphone[10], maddress[33], ch ;
int m2code=0, mcode=0 ;
int valid ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"EXIT(0)" ;
gotoxy(20,7) ;
cout <<"ENTER MEMBERS CODE NO.TO BE
MODIFIED" ;
gotoxy(20,8) ;
105
cout <<" OR ";
gotoxy(20,9) ;
cout <<" PRESS <ENTER> FOR MEMBER CATALOG
";
gets(m1code) ;
m2code = atoi(m1code) ;
mcode = m2code ;
if (m1code[0] == '0')
return ;
if (strlen(m1code) == 0)
M.list() ;
else
break ;
}
if (mcode == 0)
{
valid = 0 ;
gotoxy(5,25) ;
cout <<"\7PLEASE ENTER CORRECTLY!!" ;
getch() ;
}
if (valid && !member_found(mcode))
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7NO SUCH RECORD FOUND" ;
gotoxy(5,14) ;
cout <<"PRESS <ESC> TO EXIT OR ANY OTHER KEY
TO CONT..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"EXIT (0)" ;
CUSTOMER::display(mcode) ;
do
{
gotoxy(5,10) ; clreol() ;
cout <<"DO YOU WANT TO MODIFY THIS RECORD ?
(Y/N) " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
106
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
gotoxy(5,13) ;
cout <<"NAME : " ;
gotoxy(5,14) ;
cout <<"PHONE : " ;
gotoxy(5,15) ;
cout <<"ADDRESS : " ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER NEW NAME OF THE CUSTOMER OR
<ENTER> FOR NO CHANGE" ;
gotoxy(19,13) ; clreol() ;
gets(mname) ;
strupr(mname) ;
if (mname[0] == '0')
return ;
if (strlen(mname) > 25)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7PLEASE ENTER CORRECTLY :- 1..25)" ;
getch() ;
}
} while (!valid) ;
if (strlen(mname) == 0)
strcpy(mname,membername(mcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER NEW PHONE NO. OF THE CUSTOMER
OR <ENTER> FOR NO CHANGE" ;
gotoxy(19,14) ; clreol() ;
gets(mphone) ;
if (mphone[0] == '0')
return ;
if ((strlen(mphone) < 7 && strlen(mphone) > 0) ||
(strlen(mphone) > 9))
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
107
cout <<"\7PLEASE ENTER CORRECTLY!" ;
getch() ;
}
} while (!valid) ;
if (strlen(mphone) == 0)
strcpy(mphone,memberphone(mcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER NEW ADDRESS OR <ENTER> FOR NO
CHANGE" ;
gotoxy(19,15) ; clreol() ;
gets(maddress) ;
strupr(maddress) ;
if (maddress[0] == '0')
return ;
if (strlen(maddress) > 32)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7PLEASE ENTER CORRECTLY :- 1..32)" ;
getch() ;
}
} while (!valid) ;
if (strlen(maddress) == 0)
strcpy(maddress,memberaddress(mcode)) ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(30,18) ; clreol() ;
cout <<"SAVE THIS RECORD (Y/N) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
CUSTOMER::modify(mcode,mname,mphone,maddress) ;
gotoxy(33,23) ;
cout <<"\7RECORD MODIFIED!!" ;
getch() ;
}

108
//**********************************************************
// THIS FUNCTION GIVES CD CODE TO DELETE THE CD RECORD
//**********************************************************

void WORKING :: delete_cd(void)


{
CD B ;
char t1code[5], tname[33], tcopyright[26], ch ;
int t2code=0, tcode=0 ;
int valid ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"EXIT (0)" ;
gotoxy(20,5) ;
cout <<"ENTER CODE NO. OR NAME OF THE CD TO
BE DELETED" ;
gotoxy(20,6) ;
cout <<" OR ";
gotoxy(20,7) ;
cout <<" PRESS <ENTER> FOR CD'S CATALOG " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
B.list() ;
else
break ;
}
t2code = atoi(t1code) ;
tcode = t2code ;
if ((tcode == 0 && !cdname_found(t1code)) || (tcode != 0 && !
cd_found(tcode)))
{
valid = 0 ;
gotoxy(5,10) ;
cout <<"\7NO SUCH RECORDS" ;
gotoxy(5,11) ;
cout <<"PRESS <ESC> TO EXIT OR ANY OTHER KEY
TO CONT..." ;
ch = getch() ;
if (ch == 27)
109
return ;
}
} while (!valid) ;
if (tcode == 0)
tcode = cdcodeof(t1code) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"EXIT (0)" ;
CD::display(tcode) ;
do
{
gotoxy(5,13) ; clreol() ;
cout <<"WANT TO DELETE THIS RECORD ?(Y/N) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
int tavail, tcopies ;
tavail = available(tcode) ;
tcopies = no_of_copies(tcode) ;
if (tavail != tcopies)
{
gotoxy(5,15) ;
cout <<"\7CANNOT DELETE THE RECORD.CD IS ISSUED
TO SOMEONE" ;
getch() ;
return ;
}
CD::delete_rec(tcode) ;
gotoxy(33,23) ;
cout <<"\7RECORD DELETED!!" ;
getch() ;
}

//**********************************************************
// THIS FUNCTION GIVES CUSTOMER CODE TO DELETE THE CUSTOMER
// RECORD
//**********************************************************

void WORKING :: delete_member(void)


{
CUSTOMER M ;
110
char m1code[5], mname[26], mphone[10], maddress[33], ch ;
int m2code=0, mcode=0 ;
int valid ;
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"EXIT (0)" ;
gotoxy(20,7) ;
cout <<"ENTER CODE NO. OF THE CUSTOMER TO
BE DELETED" ;
gotoxy(20,8) ;
cout <<" OR ";
gotoxy(20,9) ;
cout <<" PRESS <ENTER> FOR MEMBERS
CATALOG " ;
gets(m1code) ;
m2code = atoi(m1code) ;
mcode = m2code ;
if (m1code[0] == '0')
return ;
if (strlen(m1code) == 0)
M.list() ;
else
break ;
}
if (mcode == 0)
{
valid = 0 ;
gotoxy(5,25) ;
cout <<"\7PLEASE ENTER CORRECTLY!!" ;
getch() ;
}
if (valid && !member_found(mcode))
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7NO SUCH RECORD FOUND" ;
gotoxy(5,14) ;
cout <<"PRESS <ESC> TO EXIT OR ANY OTHER KEY
TO CONT..." ;
ch = getch() ;
if (ch == 27)
111
return ;
}
} while (!valid) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"EXIT (0)" ;
CUSTOMER::display(mcode) ;
do
{
gotoxy(5,10) ; clreol() ;
cout <<"WANT TO DELETE THIS RECORD ?(Y/N) " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
if (issued(mcode))
{
gotoxy(5,15) ;
cout <<"\7CANNOT DELETE THE RECORD! CUSTOMER
IS HAVING A CD" ;
getch() ;
return ;
}
CUSTOMER::delete_rec(mcode) ;
gotoxy(33,23) ;
cout <<"\7RECORD MODIFIED!!" ;
getch() ;
}

//**********************************************************
// MAIN FUNCTION CALLING INTRODUCTION AND MAIN MENU
//**********************************************************

void main(void)
{

MENU menu ;
menu.introduction() ;
menu.main_menu() ;

}
112
CHAPTER 8
RESULTS & CONCLUSION

This software is developed to perform following operations :-

a. Right information can be provided to right person at the right time.

b. Modification or deletion of records in the menu.

c. To provide accurate data keeping in a manner so as to provide fast and easy


access.

d. The system will save the time in preparation of routine reports at each level of
computerization.

e. The system also helps in raising the technical standard of the staff in the domain

of the computer technique.

113
REFERENCES

1. E. Balagrursamy, Programming in ANSI C, Tata McGraw-Hill, 1992.

2. E. Balagrursamy, Object-Oriented Programming with C++.

3. Robert Lafore, Object-Oriented Programming in Turbo C++, Waite Group,


1999.

4. Bjarne Stroustrup, The C++ Programming Language, 3rd edition, Addison-


Wesley, 1997.

114

You might also like