-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddressBook.cs
77 lines (75 loc) · 3.1 KB
/
AddressBook.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//-----------------------------------------------------------------------
// <copyright file="AddressBook.cs" company="CompanyName">
// Company copyright tag.
// </copyright>
//-----------------------------------------------------------------------
namespace OopsPrograms
{
using System;
/// <summary>
/// this class is used for storing the data of a person
/// </summary>
public class AddressBook
{
/// <summary>
/// Addresses the book details.
/// </summary>
/// <exception cref="Exception">casting exception</exception>
public void AddressBookDetails()
{
try
{
////this variable is used for cases in the switch case
int caseCondition;
////this variable is used for do while termination
string doCondition = null;
do
{
Console.WriteLine("enter 1 for add person");
Console.WriteLine("enter 2 for edit information");
Console.WriteLine("enter 3 for delete person");
Console.WriteLine("enter 4 for sort by last name");
Console.WriteLine("enter 5 for sort by zip");
Console.WriteLine("enter 6 for print address book ");
caseCondition = Convert.ToInt32(Console.ReadLine());
////creating the object of address utility class
AddressUtility addressUtility = new AddressUtility();
switch (caseCondition)
{
case 1:
////this case is used for adding person
addressUtility.AddPerson();
break;
case 2:
////this case is used for update
addressUtility.Update();
break;
case 6:
////this case is used for printing the address book
addressUtility.PrintAddressBook();
break;
case 3:
////this data is used for delete data in address book
addressUtility.DeleteData();
break;
case 4:
////this case is used for sorting by the last name
addressUtility.SortByLastName();
break;
case 5:
////this case is used for sorting the by zip Code
addressUtility.SortByZip();
break;
}
Console.WriteLine("enter y to continue");
doCondition = Console.ReadLine();
}
while (doCondition.Equals("y"));
}
catch (Exception e)
{
throw new Exception(e.Message);
}
}
}
}