forked from Zoremeth/englishDictionary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Entries.cs
79 lines (71 loc) · 2.28 KB
/
Entries.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
78
79
using System;
namespace Dictionary
{
class Entries
{
static void Main()
{
Dictionary defineDictionary = new Dictionary();
var dictionary = defineDictionary.englishDictionary;
}
public void AddEntry()
{
Console.WriteLine("Add entry");
Console.WriteLine("Enter word:");
string word = Console.ReadLine();
Console.WriteLine("Enter definition:");
string definition = Console.ReadLine();
Console.WriteLine("Adding entry: {0}, {1}", word, definition);
Dictionary.Add(word, definition);
}
public void DeleteEntry()
{
Console.WriteLine("What entry would you like to delete?:");
ListKeys();
string delKey = Console.ReadLine();
Console.WriteLine("Deleting entry: {0}", delKey);
if (dictionary.ContainsKey(delKey))
{
dictionary.Remove(delKey);
}else{
Console.WriteLine("Could not find entry.");
}
}
public void ChangeEntry()
{
Console.WriteLine("What value would you like to change?");
ListKeys();
string input = Console.ReadLine();
if(dictionary.ContainsKey(input)){
Console.WriteLine("What would you like to change it to?");
string correction = Console.ReadLine();
dictionary.Remove(input);
dictionary.Add(correction, "Test");
}else{
Console.WriteLine("Entry does not exist");
}
}
public void ListAll()
{
Console.WriteLine("Currently stored entries:");
foreach (var entries in dictionary)
{
Console.WriteLine("{0}, {1}", entries.Key, entries.Value);
}
}
public void ListKeys()
{
foreach (var key in dictionary)
{
Console.WriteLine("{0}", key.Key);
}
}
public void ListValues()
{
foreach (var values in dictionary)
{
Console.WriteLine("{0}", values.Value);
}
}
}
}