-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
62 lines (59 loc) · 2.4 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
using System;
namespace generator_pitanja_za_ispit
{
internal class Program
{
static List<string> questionsList = new List<string>();
static string fileName = "zadaci.txt";
static string[] allQuestionBase = { };
static void Main(string[] args)
{
Question q = new Question(questionsList);
Console.WriteLine("Dobrodosli na generator pitanja za ispite");
Console.Write("Unesi putanju ka bazi: ");
string databasePath = Console.ReadLine();
try
{
allQuestionBase = File.ReadAllLines(databasePath);
}catch (Exception ex)
{
Console.WriteLine("Unos datoteke nije validna");
ProgramHandling.ExitProgram();
}
Console.Write($"Napisi koliko pitanja zelis od 1 do {allQuestionBase.Length}: ");
int questionNo = 0;
string userQuestioNo = Console.ReadLine();
if (!Int32.TryParse(userQuestioNo, out questionNo))
{
Console.WriteLine("Unos nije ispravan!");
Console.WriteLine("Gasim program!");
ProgramHandling.ExitProgram();
}
if (questionNo > allQuestionBase.Length)
{
Console.WriteLine("Broj pitanja ne sme da bude veci od broj baza pitanja");
ProgramHandling.ExitProgram();
}else if (questionNo <= 0)
{
Console.WriteLine("Broj pitanja ne sme da bude manji ili jednak nuli");
ProgramHandling.ExitProgram();
}
Console.Write("Unesi putanju za cuvanje pitanja (*.txt) ili pretisni enter ako zelis u root programa da cuvas: ");
string questionBase = Console.ReadLine();
if (questionBase == "")
{
questionBase = new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.FullName + fileName;
}
else if(!questionBase.Contains(".txt"))
{
questionBase += ".txt";
}
q.GenerateQuestions(questionNo, allQuestionBase);
q.WriteQuestions(questionBase);
Console.WriteLine("=====PITANJA=====");
q.PrintAllQuestions();
Console.WriteLine("=====KRAJ PITANJA=====");
ProgramHandling.ExitProgram();
}
}
}