0% found this document useful (0 votes)
19 views

OOP Mini Project_034440

Uploaded by

twwydjf9bc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

OOP Mini Project_034440

Uploaded by

twwydjf9bc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

“Mini-Project Title”

Object-Oriented Programming Mini Project

Submitted by

Vipul Patil (SB66)

Pushkar Patil (SB45)

Rutik Paymode (SB48)

Om Shinde (SB58)

Yash Patil (SB47)

SECOND YEAR COMPUTER ENGINEERING

Under the Guidance of

Dr. Deepak S. Uplaonkar

Department of Computer Engineering


Hope Foundation's
International Institute of Information Technology
Hinjawadi, Pune – 411057

AY 2024-2025
Semester-1
TABLE OF CONTENTS

(Page Number)

1. PROBLEM STATEMENT 2

2. INTRODUCTION 3

3. ALGORITHM AND FLOWCHART 4

4. REQUIREMENTS 4

4.1 SOFTWARE AND HARDWARE DETAILS 6

4.2 LIBRARIES / PACKAGES USED 6

5. RESULT 7

6. CONCLUSION 10

7. REFERENCES 10

2 Department of computer engineering I2IT, Pune


1 PROBLEM STATEMENT

Write a menu driven program that will create a data file containing the list of
telephone numbers in the following form

John 23456
Ahmed 9876
........... .........

• Use a class object to store each set of data, access the file created and implement
the following tasks
• Determine the telephone number of specified person
• Determine the name if telephone number is known
• Update the telephone number, whenever there is a change.

2 INTRODUCTION
This system is a simple, menu-driven program developed in Python, aimed at managing a list of
telephone numbers. It utilizes a class structure to store contact information and stores this data in
a file for persistent access.

Each contact entry includes:


- Name: The contact's name.
- Telephone Number: The contact's phone number.

The program offers several features, allowing users to:


1. Look up a contact’s phone number by entering their name.
2. Find the name of a contact based on a provided phone number.
3. Update contact information when a phone number changes.

With these capabilities, the system is a useful tool for keeping and updating contact information,
making it ideal for small-scale use cases where contacts need to be stored and retrieved easily.

3 Department of computer engineering I2IT, Pune


3 ALGORITHM AND FLOWCHART

ALGORITHM:

1. Define Class `TelephoneEntry`


- Create a class `TelephoneEntry` with attributes:
- `name`: to store the name of a contact.
- `number`: to store the telephone number of a contact.
- Define methods for managing entries (adding, finding, updating, deleting, and displaying
contacts).

2.Implement `addEntry` Method


- Prompt the user to enter a name and telephone number.
- Open the file in append mode.
- Write the name and number to the file.
- Close the file.

3. Implement `findNumberByName` Method


- Prompt the user for the name to search.
- Open the file in read mode.
- Initialize a `found` flag as `false`.
- For each line in the file:
- Read the `name` and `number`.
- If the `name` matches the search name:

- Print the `number`, set `found` to `true`, and break the loop.
- If `found` remains `false`, print "Name not found."
- Close the file.

4. Implement `findNameByNumber` Method


- Prompt the user for the phone number to search.
- Open the file in read mode.
- Initialize a `found` flag as `false`.

4 Department of computer engineering I2IT, Pune


- For each line in the file:
- Read the `name` and `number`.
- If the `number` matches the search number:

- Print the `name`, set `found` to `true`, and break the


loop.
- If `found` remains `false`, print "Number not found."
- Close the file.

5. Implement `delNameByNumber` Method


- Prompt the user for the name to delete.
- Open the file in read mode and a temporary file in write mode.
- Initialize a `found` flag as `false`.
- For each line in the file:
- Read the `name` and `number`.
- If the `name` matches the search name:

- Set `found` to `true` (do not copy the entry to the temporary file).
- Otherwise, write the `name` and `number` to the temporary file.
- Close both files.
- Replace the original file with the temporary file.
- If `found` is `true`, print "Number deleted successfully"; otherwise, print "Name not found."

6. Implement `updateNumber` Method


- Prompt the user for the name to update and the new phone number.
- Open the file in read mode and a temporary file in write mode.
- Initialize a `found` flag as `false`.
- For each line in the file:
- Read the `name` and `number`.
- If the `name` matches the search name:

- Write the `name` and `newNumber` to the temporary file, set `found` to `true`.
- Otherwise, write the original `name` and `number` to the temporary file.

5 Department of computer engineering I2IT, Pune


- Close both files.
- Replace the original file with the temporary file.
- If `found` is `true`, print "Number updated successfully"; otherwise, print "Name not found."

7. Implement `displayEntries` Method


- Open the file in read mode.
- For each line in the file:
- Read and display each `name` and `number`.

- Close the file.

8. Main Menu (in `main()` function)


- Present a menu to the user with options to:
1. Add an entry
2. Find a number by name
3. Find a name by number
4. Update a number
5. Display all entries
6. Delete an entry by name
7. Exit the program

- Prompt the user for their choice.


- Based on the choice, call the corresponding method in the `TelephoneEntry` class.
- Repeat until the user selects the "Exit" option.

6 Department of computer engineering I2IT, Pune


FLOWCHART:

4 REQUIREMENTS

4.1 SOFTWARE REQUIREMENTS


VS CODE, Text document

4.2 LIBRARIES/PACKAGES USED


iostream, fstream, string

7 Department of computer engineering I2IT, Pune


5 RESULT

Menu:
1. Add Entry
2. Find Number by Name
3. Find Name by Number
4. Update Number
5. Display All Entries
6. Delete Number
7. Exit
Enter your choice: 1
Enter name: A
Enter telephone number: 123

Menu:
1. Add Entry
2. Find Number by Name
3. Find Name by Number
4. Update Number
5. Display All Entries
6. Delete Number
7. Exit
Enter your choice: 1
Enter name: B
Enter telephone number: 456

Menu:
1. Add Entry
2. Find Number by Name
3. Find Name by Number
4. Update Number
5. Display All Entries
6. Delete Number
7. Exit
Enter your choice: 5
A: 123
B: 456

Menu:
1. Add Entry
2. Find Number by Name
3. Find Name by Number
4. Update Number
5. Display All Entries
6. Delete Number
7. Exit

8 Department of computer engineering I2IT, Pune


Enter your choice: 4
Enter name to update: B
Enter new number: 789
Number updated successfully

Menu:
1. Add Entry
2. Find Number by Name
3. Find Name by Number
4. Update Number
5. Display All Entries
6. Delete Number
7. Exit
Enter your choice: 5
A: 123
B: 789

Menu:
1. Add Entry
2. Find Number by Name
3. Find Name by Number
4. Update Number
5. Display All Entries
6. Delete Number
7. Exit
Enter your choice: 6
Enter Name to Delete: A
Number deleted successfully

Menu:
1. Add Entry
2. Find Number by Name
3. Find Name by Number
4. Update Number
5. Display All Entries
6. Delete Number
7. Exit
Enter your choice: 5
B: 789

Menu:
1. Add Entry
2. Find Number by Name
3. Find Name by Number
4. Update Number
5. Display All Entries

9 Department of computer engineering I2IT, Pune


6. Delete Number
7. Exit
Enter your choice: 2
Enter name to search: B
Telephone number of B is 789

Menu:
1. Add Entry
2. Find Number by Name
3. Find Name by Number
4. Update Number
5. Display All Entries
6. Delete Number
7. Exit
Enter your choice: 7
Exiting...

6 CONCLUSION
This C++ program implements a simple telephone directory system that allows users to add,
search, update, display, and delete entries in a text file. It provides a basic menu-driven interface
for interacting with the directory. File handling is used for storing and modifying data, while
basic error handling ensures the program runs smoothly. While functional, the program could be
improved with input validation, case-insensitive searches, and a more structured data format for
scalability. Overall, it's an effective, lightweight solution for managing a small set of telephone
entries.

7 REFERENCES
o GeeksforGeeks - C++ Data Structures
o cppreference: File Input/Output

10 Department of computer engineering I2IT, Pune

You might also like