-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
70 lines (63 loc) · 2.43 KB
/
Program.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
//Coded by Rubseena N U
namespace greektrust_TameofThrones
{
//Derived Class named as Program(Inheritance)
class Program : CipherFunction
{
public void ReadFromFile(string filePath)
{
KingdomSelection objkingdom = new KingdomSelection();
PropertyClass objProperty = new PropertyClass();
string filename = Path.GetFullPath(filePath);
try
{
List<string> result = new List<string>();
string secretMessage = string.Empty, nameOfKingdom, nameOfEmblem, encryptedValue;
nameOfKingdom = nameOfEmblem = encryptedValue = string.Empty;
bool containsAllKeyWords;
string[] inputLines = File.ReadAllLines(filename);
foreach (string line in inputLines)
{
string[] strKingdom = line.Split(new char[0]);
nameOfKingdom = strKingdom[0];
secretMessage = strKingdom[1];
nameOfEmblem = objkingdom.Animal(nameOfKingdom);
encryptedValue = Encypher(nameOfEmblem, nameOfEmblem.Length).ToUpper();
if ((containsAllKeyWords = encryptedValue.All(secretMessage.Contains)) == true)
{
result.Add(nameOfKingdom);
}
}
Console.WriteLine("Output :\n");
if (result.Count >= 3)
{
Console.Write("SPACE ");
foreach (string resultSet in result)
{
Console.Write(resultSet + " ");
}
}
else
{
Console.Write("NONE");
}
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
}
static void Main(string[] args)
{
string filePath = @"D:\GreekTrustInterview\Tame_of_Thrones_1\Tame_of_Thrones_1\File\input1.txt";
Program objProgram = new Program();
objProgram.ReadFromFile(filePath);
}
}
}