Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Coursework_TI-41_Oleksiy_Artur.doc
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
520 Кб
Скачать
☆

Список використаних джерел

  1. Шилдт Г. C# 4.0 Полное руководство – М.: Вильямс, 2011. – 304с.

  2. Эндрю Троелсен. Язык Программирования C# 5.0 и платформа .NET 4.5 (6-е издание 2013). – 322с.

  3. Бишоп Дж., Хорспул Н. C# в кратком изложении. – М.: Бином. Лаборатория знаний, 2005. – 472с.

  4. Прайс Д., Гандэрлой М. Visual C# .NET. Полное руководство. – К.: ВЕК+, СПб.: КОРОНА принт, К.: НТИ, М.: Энтроп, 2004. – 960с.

  5. http://cyberforum.ru

  1. http://msdn.microsoft.com

Додаток 1

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Collections;

namespace Kurs_2

{

public enum position { student = 1, undergraduate, postgraduate, lecturer, senior_lecturer, associate, professor }

//Інтерфейс дата

public interface Date

{

int Day

{

set;

get;

}

int Month

{

set;

get;

}

int Year

{

set;

get;

}

void Display();

}

//клас Person

public class Person : Date

{

int day = 1;

int month = 1;

int year = 1990;

string name = "";

string surname = "";

public String Name

{

get { return name; }

set { name = value; }

}

public String Surname

{

get { return surname; }

set { surname = value; }

}

public int Day

{

set

{

if (value > 0 && value <= 31)

day = value;

}

get

{

return day;

}

}

public int Month

{

set

{

if (value > 0 && value <= 12)

month = value;

}

get

{

return month;

}

}

public int Year

{

set

{

if (value > 1990 && value <= 1999)

year = value;

}

get

{

return year;

}

}

public Person() { }

public Person(int dayOfBirth, int monthOfBirth, int yearOfBirth, string name, string surname)

{

Day = dayOfBirth;

Month = monthOfBirth;

Year = yearOfBirth;

Name = name;

Surname = surname;

}

public Person(int dayOfBirth, int monthOfBirth, int yearOfBirth) : this(dayOfBirth, monthOfBirth, yearOfBirth, "", "") { }

public Person(string name, string surname) : this(0, 0, 0, name, surname) { }

public virtual void Display()

{

Console.WriteLine("-----------------------------");

Console.WriteLine("| Person |");

Console.WriteLine("|---------------------------|");

Console.WriteLine("|Date of birth: " + Day + "." + Month + "." + Year + "\t");

Console.WriteLine("|---------------------------|");

Console.WriteLine("|Name of Person: " + Name + " " + Surname + "|");

Console.WriteLine("|----------------------|");

}

}

//клас author

public class Author : Person

{

string autorPosition = "";

public string AutorPosition

{

get { return autorPosition; }

set { autorPosition = value; }

}

int codePosition = 0;

public Author() { }

public Author(int day, int month, int year, string name, string surname, Kurs_2.position posit)

: base(day, month, year, name, surname)

{

switch (posit)

{

case position.student:

AutorPosition = "student";

break;

case position.undergraduate:

AutorPosition = "undergraduate";

break;

case position.postgraduate:

AutorPosition = "postgraduate";

break;

case position.lecturer:

AutorPosition = "lecturer";

break;

case position.senior_lecturer:

AutorPosition = "senior_lecturer";

break;

case position.associate:

AutorPosition = "associate";

break;

case position.professor:

AutorPosition = "professor";

break;

default:

AutorPosition = "unknow position";

break;

}

}

public override void Display()

{

{

base.Display();

Console.WriteLine("|Position: " + AutorPosition + "\t|");

Console.WriteLine("|----------------------|");

}

}

}

//інтерейс Subject

public interface Subject

{

string Topic1

{

get;

set;

}

string Topic2

{

get;

set;

}

string Topic3

{

get;

set;

}

string Topic4

{

get;

set;

}

void Display();

}

//клас Thesis

public class Thesis : Date, Subject

{

Program.Del del;

Author[] authorList;

string title = "";

int dayPod = 1;

int monthPod = 1;

int yearPod = 2016;

string topic1 = "";

string topic2 = "";

string topic3 = "";

string topic4 = "";

public Author[] AuthorList

{

get { return authorList; }

set { authorList = value; }

}

public string Title

{

get { return title; }

set { title = value; }

}

public string Topic1

{

get { return topic1; }

set { topic1 = value; }

}

public string Topic2

{

get { return topic2; }

set { topic2 = value; }

}

public string Topic3

{

get { return topic3; }

set { topic3 = value; }

}

public string Topic4

{

get { return topic4; }

set { topic4 = value; }

}

public int Day

{

get { return dayPod; }

set { dayPod = value; }

}

public int Month

{

get { return monthPod; }

set { monthPod = value; }

}

public int Year

{

get { return yearPod; }

set { yearPod = value; }

}

public Thesis() { }

public Thesis(string title, Subject subject, int dayOfPodannya, int monthOfPodannya, int yearOfPodannya, Author[] authorList)

{

Title = title;

Topic1 = subject.Topic1;

Topic2 = subject.Topic2;

Topic3 = subject.Topic3;

Topic4 = subject.Topic4;

Day = dayOfPodannya;

Month = monthOfPodannya;

Year = yearOfPodannya;

this.AuthorList = authorList;

}

public Thesis(string title, string topic1, string topic2, string topic3, string topic4, int dayOfPodannya, int monthOfPodannya, int yearOfPodannya, Author[] authorList)

{

Title = title;

Topic1 = topic1;

Topic2 = topic2;

Topic3 = topic3;

Topic4 = topic4;

Day = dayOfPodannya;

Month = monthOfPodannya;

Year = yearOfPodannya;

this.AuthorList = authorList;

}

public Author this[int index]

{

get

{

if (index >= 0 && index < authorList.Length)

return authorList[index];

else

return authorList[authorList.Length - 1];

}

set

{

if (index >= 0 && index < authorList.Length)

authorList[index] = value;

else

authorList[0] = value;

}

}

public void Display()

{

{

Console.WriteLine("-----------------------------");

Console.WriteLine("| Person |");

Console.WriteLine("|---------------------------|");

for (int i = 0; i < authorList.Length; i++)

{

authorList[i].Display();

}

Console.WriteLine("|---------------------------|");

Console.WriteLine("|Topics: " + Topic1 + " " + Topic2 + " " + Topic3 + " " + Topic4 + " |");

Console.WriteLine("|---------------------------|");

Console.WriteLine("|Date of rendering: " + Day + "." + Month + "." + Year + "|");

}

}

}

//Клас Abstract

public class Abstract : Date

{

Thesis[] theseList;

int dayVip = 0;

int monthVip = 0;

int yearVip = 0;

public Thesis[] TheseList

{

get { return theseList; }

set { theseList = value; }

}

public int Day

{

get { return dayVip; }

set { dayVip = value; }

}

public int Month

{

get { return monthVip; }

set { monthVip = value; }

}

public int Year

{

get { return yearVip; }

set { yearVip = value; }

}

int numberOfPages;

public Abstract() { }

public int NumberOfPages

{

set { numberOfPages = value; }

get { return numberOfPages; }

}

//public Abstract() { }

public Abstract(int numberOfPages, Thesis[] theseList, int dayVip, int monthVip, int yearVip)

{

Day = dayVip;

Month = monthVip;

Year = yearVip;

NumberOfPages = numberOfPages;

this.theseList = theseList;

}

public static int AbsList(Abstract[] abstractList)

{

return abstractList.Length;

}

public static int TesList(Abstract[] abstractList)

{

int index = 0;

for (int i = 0; i < abstractList.Length; i++)

{

index += abstractList[i].TheseList.Length;

}

return index;

}

public static int AutList(Abstract[] abstractList)

{

int abstractlength = abstractList.Length;

int authorindex = 0;

for (int i = 0; i < abstractlength; i++)

{

for (int j = 0; j < abstractList[i].TheseList.Length; j++)

{

authorindex += abstractList[i].TheseList[j].AuthorList.Length;

}

}

return authorindex;

}

public static void Out(int absList, int tesList, int autList)

{

Console.WriteLine("In {0} abstracts, there are {1} theses and {2} authors", absList, tesList, autList);

}

public static Abstract operator +(Abstract abs1, Abstract abs2)

{

Abstract result = new Abstract();

result.numberOfPages = abs1.NumberOfPages + abs2.NumberOfPages;

result.theseList = new Thesis[abs1.theseList.Length + abs2.theseList.Length];

for (int i = 0; i < abs1.theseList.Length; i++)

{

result.theseList[i] = abs1.theseList[i];

}

for (int i = abs1.theseList.Length; i < abs1.theseList.Length; i++)

{

result.theseList[i] = abs1.theseList[i];

}

return result;

}

public static bool operator >(Abstract thsc1, Abstract thsc2)

{

if (thsc1.theseList.Length > thsc2.theseList.Length)

return true;

else

return false;

}

public static bool operator <(Abstract thsc1, Abstract thsc2)

{

if (thsc1.theseList.Length < thsc2.theseList.Length)

return true;

else

return false;

}

public static bool operator true(Abstract thsc)

{

if (thsc.theseList.Length != 0)

return true;

else

return false;

}

public static bool operator false(Abstract thsc)

{

if (thsc.theseList.Length == 0)

return true;

else

return false;

}

public Thesis this[int index]

{

get

{

if (index >= 0 && index < theseList.Length)

return theseList[index];

else

return theseList[theseList.Length - 1];

}

set

{

if (index >= 0 && index < theseList.Length)

theseList[index] = value;

else

theseList[0] = value;

}

}

public void Display()

{

{

Console.WriteLine("-----------------------------");

Console.WriteLine("| Person |");

Console.WriteLine("|---------------------------|");

for (int i = 0; i < theseList.Length; i++)

theseList[i].Display();

Console.WriteLine("|---------------------------|");

Console.WriteLine("| Number of pages: " + " " + NumberOfPages + " |");

Console.WriteLine("|---------------------------|");

Console.WriteLine("|Date of vip: " + Day + "." + Month + "." + Year + "|");

}

}

}

//клас Program

class Program

{

public delegate int MasObject(Abstract[] abstactClass);

public delegate void OutToDisplay(int absList, int tesList, int autList);

public delegate void Del(Object obj);

public static Abstract[] objectFill(int dayOfBirth, int monthOfBirth, int yearOfBirth, string name, string surname, position position, string topic1, string topic2, string topic3, string topic4, string tezaTitle, int dateOfPresent, int monthOfPresent, int yearOfPresent, int dateOfPublish, int monthOfPublish, int yearOfPublish, int totalNumOfPag)

{

Abstract[] abstractClass = new Abstract[1];

Subject subject = new Thesis();

return abstractClass;

}

public Kurs_2.position enterEnum()

{

int inp = int.Parse(Console.ReadLine());

Kurs_2.position posit;

switch (inp)

{

case 1:

posit = Kurs_2.position.student;

break;

case 2:

posit = Kurs_2.position.undergraduate;

break;

case 3:

posit = Kurs_2.position.postgraduate;

break;

case 4:

posit = Kurs_2.position.lecturer;

break;

case 5:

posit = Kurs_2.position.senior_lecturer;

break;

case 6:

posit = Kurs_2.position.associate;

break;

case 7:

posit = Kurs_2.position.professor;

break;

default:

posit = enterEnum();

break;

}

return posit;

}

public static void Main()

{

int vvod = 0;

Abstract[] abstractClass = new Abstract[10];

ArrayList theselist = new ArrayList();

Author[] authorList = new Author[3];

Kurs_2.position posit = Kurs_2.position.student;

authorList[0] = new Author(11, 10, 1996, "Aman", "Hadjiev", posit);

authorList[1] = new Author(12, 8, 1996, "Andriy", "Bileckiy", posit);

authorList[2] = new Author(11, 10, 1997, "Andiy", " Androsiuk", posit);

Console.ReadKey();

Thesis theseList = new Thesis("TITLE1", "a1", "a2", "a3", "a4", 10, 12, 2015, authorList);

theselist.Add(theseList);

theseList = new Thesis("TITLE2", "a11", "a22", "a33", "a44", 9, 11, 2014, authorList);

theselist.Add(theseList);

Thesis[] tlist = new Thesis[theselist.Count];

for (int i = 0; i < theselist.Count; i++)

{

tlist[i] = (Thesis)theselist[i];

}

abstractClass[0] = new Abstract(120, tlist, 1, 2, 2016);

authorList = new Author[2];

theselist.Clear();

posit = Kurs_2.position.undergraduate;

authorList[0] = new Author(11, 10, 1996, "Amana", "Hadjieva", posit);

authorList[1] = new Author(11, 10, 1996, "Ama", "Hadjie", posit);

theseList = new Thesis("TITLE1", "a1", "a2", "a3", "a4", 10, 12, 2015, authorList);

theselist.Add(theseList);

theseList = new Thesis("TITLE2", "a1", "a2", "a3", "a4", 9, 11, 2014, authorList);

theselist.Add(theseList);

tlist = null;

tlist = new Thesis[theselist.Count];

for (int i = 0; i < theselist.Count; i++)

{

tlist[i] = (Thesis)theselist[i];

//tlist[i].Display();

}

abstractClass[1] = new Abstract(135, tlist, 1, 2, 2016);

authorList = new Author[2];

theselist.Clear();

posit = Kurs_2.position.lecturer;

authorList[0] = new Author(11, 10, 1996, "Amana", "Hadjieva", posit);

posit = Kurs_2.position.undergraduate;

authorList[1] = new Author(11, 10, 1996, "Ama", "Hadjie", posit);

theseList = new Thesis("TITLE1", "a1", "a2", "a3", "a4", 10, 12, 2015, authorList);

theselist.Add(theseList);

theseList = new Thesis("TITLE2", "a1", "a2", "a3", "a4", 9, 11, 2014, authorList);

theselist.Add(theseList);

tlist = null;

tlist = new Thesis[theselist.Count];

for (int i = 0; i < theselist.Count; i++)

{

tlist[i] = (Thesis)theselist[i];

}

abstractClass[2] = new Abstract(111, tlist, 1, 2, 2016);

authorList = new Author[2];

theselist.Clear();

posit = Kurs_2.position.undergraduate;

authorList[0] = new Author(11, 10, 1996, "Amana", "Hadjieva", posit);

authorList[1] = new Author(11, 10, 1996, "Ama", "Hadjie", posit);

theseList = new Thesis("TITLE1", "a1", "a2", "a3", "a4", 10, 12, 2015, authorList);

theselist.Add(theseList);

theseList = new Thesis("TITLE2", "a1", "a2", "a3", "a4", 9, 11, 2014, authorList);

theselist.Add(theseList);

tlist = null;

tlist = new Thesis[theselist.Count];

for (int i = 0; i < theselist.Count; i++)

{

tlist[i] = (Thesis)theselist[i];

//tlist[i].Display();

}

abstractClass[3] = new Abstract(125, tlist, 1, 2, 2016);

authorList = new Author[2];

theselist.Clear();

posit = Kurs_2.position.professor;

authorList[0] = new Author(11, 10, 1996, "Amana", "Hadjieva", posit);

authorList[1] = new Author(11, 10, 1996, "Ama", "Hadjie", posit);

theseList = new Thesis("TITLE1", "a1", "a2", "a3", "a4", 10, 12, 2015, authorList);

theselist.Add(theseList);

theseList = new Thesis("TITLE2", "a1", "a2", "a3", "a4", 9, 11, 2014, authorList);

theselist.Add(theseList);

tlist = null;

tlist = new Thesis[theselist.Count];

for (int i = 0; i < theselist.Count; i++)

{

tlist[i] = (Thesis)theselist[i];

}

abstractClass[4] = new Abstract(127, tlist, 1, 2, 2016);

authorList = new Author[2];

theselist.Clear();

posit = Kurs_2.position.senior_lecturer;

authorList[0] = new Author(11, 10, 1996, "Amana", "Hadjieva", posit);

authorList[1] = new Author(11, 10, 1996, "Ama", "Hadjie", posit);

theseList = new Thesis("TITLE1", "a1", "a2", "a3", "a4", 10, 12, 2015, authorList);

theselist.Add(theseList);

theseList = new Thesis("TITLE2", "a1", "a2", "a3", "a4", 9, 11, 2014, authorList);

theselist.Add(theseList);

tlist = null;

tlist = new Thesis[theselist.Count];

for (int i = 0; i < theselist.Count; i++)

{

tlist[i] = (Thesis)theselist[i];

}

abstractClass[5] = new Abstract(122, tlist, 1, 2, 2016);

authorList = new Author[2];

theselist.Clear();

posit = Kurs_2.position.undergraduate;

authorList[0] = new Author(11, 10, 1996, "Amana", "Hadjieva", posit);

authorList[1] = new Author(11, 10, 1996, "Ama", "Hadjie", posit);

theseList = new Thesis("TITLE1", "a1", "a2", "a3", "a4", 10, 12, 2015, authorList);

theselist.Add(theseList);

theseList = new Thesis("TITLE2", "a1", "a2", "a3", "a4", 9, 11, 2014, authorList);

theselist.Add(theseList);

tlist = null;

tlist = new Thesis[theselist.Count];

for (int i = 0; i < theselist.Count; i++)

{

tlist[i] = (Thesis)theselist[i];

}

abstractClass[6] = new Abstract(121, tlist, 1, 2, 2016);

authorList = new Author[2];

theselist.Clear();

posit = Kurs_2.position.associate;

authorList[0] = new Author(11, 10, 1996, "Amana", "Hadjieva", posit);

authorList[1] = new Author(11, 10, 1996, "Ama", "Hadjie", posit);

theseList = new Thesis("TITLE1", "a1", "a2", "a3", "a4", 10, 12, 2015, authorList);

theselist.Add(theseList);

theseList = new Thesis("TITLE2", "a1", "a2", "a3", "a4", 9, 11, 2014, authorList);

theselist.Add(theseList);

tlist = null;

tlist = new Thesis[theselist.Count];

for (int i = 0; i < theselist.Count; i++)

{

tlist[i] = (Thesis)theselist[i];

//tlist[i].Display();

}

abstractClass[7] = new Abstract(122, tlist, 1, 2, 2016);

authorList = new Author[2];

theselist.Clear();

posit = Kurs_2.position.senior_lecturer;

authorList[0] = new Author(11, 10, 1996, "Amana", "Hadjieva", posit);

authorList[1] = new Author(11, 10, 1996, "Ama", "Hadjie", posit);

theseList = new Thesis("TITLE1", "a1", "a2", "a3", "a4", 10, 12, 2015, authorList);

theselist.Add(theseList);

theseList = new Thesis("TITLE2", "a1", "a2", "a3", "a4", 9, 11, 2014, authorList);

theselist.Add(theseList);

tlist = null;

tlist = new Thesis[theselist.Count];

for (int i = 0; i < theselist.Count; i++)

{

tlist[i] = (Thesis)theselist[i];

//tlist[i].Display();

}

abstractClass[8] = new Abstract(126, tlist, 1, 2, 2016);

authorList = new Author[2];

theselist.Clear();

posit = Kurs_2.position.undergraduate;

authorList[0] = new Author(11, 10, 1996, "Amana", "Hadjieva", posit);

authorList[1] = new Author(11, 10, 1996, "Ama", "Hadjie", posit);

theseList = new Thesis("TITLE1", "a1", "a2", "a3", "a4", 10, 12, 2015, authorList);

theselist.Add(theseList);

theseList = new Thesis("TITLE2", "a1", "a2", "a3", "a4", 9, 11, 2014, authorList);

theselist.Add(theseList);

tlist = null;

tlist = new Thesis[theselist.Count];

for (int i = 0; i < theselist.Count; i++)

{

tlist[i] = (Thesis)theselist[i];

//tlist[i].Display();

}

abstractClass[9] = new Abstract(127, tlist, 1, 2, 2016);

Console.ReadKey();

bool ex = false;

while (ex == false)

{

Console.WriteLine("1.Change object");

Console.WriteLine("2.Show object");

Console.WriteLine("3.Write to file");

Console.WriteLine("4.Read from file");

Console.WriteLine("5.Write to binary file");

Console.WriteLine("6.Read from binary file");

Console.WriteLine("7.Static function");

Console.WriteLine("8.Search");

Console.WriteLine("9.Exit");

Console.WriteLine("Enter number of regime:");

vvod = int.Parse(Console.ReadLine());

if (vvod == 1)

{

int numbObj = 0;

Console.WriteLine("Which object you want to override?");

Console.WriteLine("1. First object");

Console.WriteLine("2. Second object");

Console.WriteLine("3. Third object");

Console.WriteLine("4. Fourth object");

Console.WriteLine("5. Fifth object");

Console.WriteLine("6. Sixth object");

Console.WriteLine("7. Seventh object");

Console.WriteLine("8. Eights object");

Console.WriteLine("9. Nineth object");

Console.WriteLine("10. Tenth object");

numbObj = int.Parse(Console.ReadLine());

numbObj--;

Console.Clear();

Console.WriteLine("Enter date of release:");

Console.WriteLine("Enter day, month and year of release:");

int dayOfPublish = int.Parse(Console.ReadLine());

int monthOfPyblish = int.Parse(Console.ReadLine());

int yearOfPublish = int.Parse(Console.ReadLine());

Console.WriteLine("Enter total number of pages:");

int numberOfPages = int.Parse(Console.ReadLine());

Console.WriteLine("Enter number of abstracts:");

int numberOfAbstracts = int.Parse(Console.ReadLine());

tlist = new Thesis[numberOfAbstracts];

for (int i = 0; i < numberOfAbstracts; i++)

{

Console.WriteLine("Enter Title of {0} abstract : ", i + 1);

string title = Console.ReadLine();

Console.WriteLine("Enter titles of {0} project: ", i + 1);

Console.WriteLine("First title: ");

string title1 = Console.ReadLine();

Console.WriteLine("Second title: ");

string title2 = Console.ReadLine();

Console.WriteLine("Third title: ");

string title3 = Console.ReadLine();

Console.WriteLine("Fourth title: ");

string title4 = Console.ReadLine();

Console.WriteLine("Enter day, month and year of {0} object performance:", i + 1);

int dayOfPerformance = int.Parse(Console.ReadLine());

int monthOfPerformance = int.Parse(Console.ReadLine());

int yearOfPerformance = int.Parse(Console.ReadLine());

Console.Clear();

Console.WriteLine("Enter number of authors: ");

int numbOfAuthors = int.Parse(Console.ReadLine());

authorList = new Author[numbOfAuthors];

for (int j = 0; j < numbOfAuthors; j++)

{

Console.WriteLine("Enter name of {0} author", j + 1);

string name = Console.ReadLine();

Console.WriteLine("Enter surname of {0} author", j + 1);

string surname = Console.ReadLine();

Console.WriteLine("Enter day, month and year of {0} author", j + 1);

int dayOfBirth = int.Parse(Console.ReadLine());

int monthOfBirth = int.Parse(Console.ReadLine());

int yearOfBirth = int.Parse(Console.ReadLine());

Program program = new Program();

posit = program.enterEnum();

authorList[j] = new Author(dayOfBirth, monthOfBirth, yearOfBirth, name, surname, posit);

Console.Clear();

}

}

}

else if (vvod == 2)

{

int numbObj = 0;

Console.WriteLine("Which object you want to see?");

Console.WriteLine("1. First object");

Console.WriteLine("2. Second object");

Console.WriteLine("3. Third object");

Console.WriteLine("4. Fourth object");

Console.WriteLine("5. Fifth object");

Console.WriteLine("6. Sixth object");

Console.WriteLine("7. Seventh object");

Console.WriteLine("8. Eights object");

Console.WriteLine("9. Nineth object");

Console.WriteLine("10. Tenth object");

Console.WriteLine("11. Exit to main menu");

numbObj = int.Parse(Console.ReadLine());

numbObj--;

abstractClass[numbObj].Display();

}

else if (vvod == 3)

{

File.WriteFile(abstractClass);

}

else if (vvod == 4)

{

File.ReadFile();

}

else if (vvod == 5)

{

File.WriteBinaryFile(abstractClass);

}

else if (vvod == 6)

{

File.ReadBinaryFile();

}

else if (vvod == 7)

{

MasObject autMas = Abstract.AutList;

MasObject tesMas = Abstract.TesList;

MasObject absMas = Abstract.AbsList;

OutToDisplay output = Abstract.Out;

output(absMas(abstractClass), tesMas(abstractClass), autMas(abstractClass));

Console.ReadKey();

}

else if (vvod == 8)

{

int choise = int.Parse(Console.ReadLine());

int searchindex = 0;

switch (choise)

{

case 1:

{

string thesisName;

Console.WriteLine("Enter these name: ");

thesisName = Console.ReadLine();

int abstractclass = abstractClass.Length;

for (int i = 0; i < abstractclass; i++)

{

for (int j = 0; j < abstractClass[i].TheseList.Length; j++)

{

if (thesisName == abstractClass[i].TheseList[j].Title)

{

Console.WriteLine("");

Console.WriteLine("--------------------------------------------------------------------------------");

Console.WriteLine("\t\tThesis name: " + abstractClass[i].TheseList[j].Title);

Console.WriteLine("\t\tTopic: " + abstractClass[i].TheseList[j].Topic1 + " " + abstractClass[i].TheseList[j].Topic2 + abstractClass[i].TheseList[j].Topic3 + abstractClass[i].TheseList[j].Topic4);

Console.WriteLine("\t\tAuthors:\n");

for (int k = 0; k < abstractClass[i].TheseList[j].AuthorList.Length; k++)

{

Console.WriteLine("\t\tName: " + abstractClass[i].TheseList[j].AuthorList[k].Name + " " + abstractClass[i].TheseList[j].AuthorList[k].Surname);

Console.WriteLine("\t\tDate of birth: " + abstractClass[i].TheseList[j].AuthorList[k].Day + " " + abstractClass[i].TheseList[j].AuthorList[k].Month + " " + abstractClass[i].TheseList[j].AuthorList[k].Year);

Console.WriteLine("\t\tPosition: " + abstractClass[i].TheseList[j].AuthorList[k].AutorPosition);

}

searchindex++;

}

}

}

break;

}

case 2:

{

int thesisNumber;

Console.WriteLine("Enter number of: ");

thesisNumber = int.Parse(Console.ReadLine());

int abstractclass = abstractClass.Length;

for (int i = 0; i < abstractclass; i++)

{

for (int j = 0; j < abstractClass[i].TheseList.Length; j++)

{

if (thesisNumber == j)

{

Console.WriteLine("");

Console.WriteLine("--------------------------------------------------------------------------------");

Console.WriteLine("\t\tThesis name: " + abstractClass[i].TheseList[j].Title);

Console.WriteLine("\t\tTopic: " + abstractClass[i].TheseList[j].Topic1 + " " + abstractClass[i].TheseList[j].Topic2 + abstractClass[i].TheseList[j].Topic3 + abstractClass[i].TheseList[j].Topic4);

Console.WriteLine("\t\tAuthors:\n");

for (int k = 0; k < abstractClass[i].TheseList[j].AuthorList.Length; k++)

{

Console.WriteLine("\t\tName: " + abstractClass[i].TheseList[j].AuthorList[k].Name + " " + abstractClass[i].TheseList[j].AuthorList[k].Surname);

Console.WriteLine("\t\tDate of birth: " + abstractClass[i].TheseList[j].AuthorList[k].Day + " " + abstractClass[i].TheseList[j].AuthorList[k].Month + " " + abstractClass[i].TheseList[j].AuthorList[k].Year);

Console.WriteLine("\t\tPosition: " + abstractClass[i].TheseList[j].AuthorList[k].AutorPosition);

}

searchindex++;

}

}

}

break;

}

}

}

else if(vvod==9) {ex=true;}

else

{

Console.WriteLine("Wrong choise");

Main();

}

}

}

}

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace Kurs_2

{

public class File

{

public static void WriteFile(Abstract[] abstractClass)

{

string nameOfFile;

string path = @"D:\";

Console.Write("Введiть назву файлу: ");

nameOfFile = Console.ReadLine();

System.IO.StreamWriter file = new System.IO.StreamWriter(path + nameOfFile + ".txt", true);

try

{

file.WriteLine();

file.WriteLine();

for (int i = 0; i < abstractClass.Length; i++)

{

file.WriteLine("--------------------------------------------------------------------------------\n\n");

file.WriteLine("\t\tNumber of pages: " + abstractClass[i].NumberOfPages);

file.WriteLine("\t\tDate of publish: " + abstractClass[i].Day + "." + abstractClass[i].Month + "." + abstractClass[i].Year);

file.WriteLine("\t\tTheses list:\n");

for (int j = 0; j < abstractClass[i].TheseList.Length; j++)

{

file.WriteLine("\tTopics: " + abstractClass[i].TheseList[j].Topic1 + " " + abstractClass[i].TheseList[j].Topic2 + " " + abstractClass[i].TheseList[j].Topic3 + " " + abstractClass[i].TheseList[j].Topic4);

file.WriteLine("\tDate of rendering: " + abstractClass[i].TheseList[j].Day + "." + abstractClass[i].TheseList[j].Month + "." + abstractClass[i].TheseList[j].Year + " ");

for (int k = 0; k < abstractClass[i].TheseList[j].AuthorList.Length; k++)

{

file.WriteLine("\tPosition" + abstractClass[i].TheseList[j].AuthorList[k].AutorPosition + " ");

file.WriteLine("\tName of author" + abstractClass[i].TheseList[j].AuthorList[k].Name + " " + abstractClass[i].TheseList[j].AuthorList[k].Surname);

file.WriteLine("\tDate of birth" + abstractClass[i].TheseList[j].AuthorList[k].Day + "." + abstractClass[i].TheseList[j].AuthorList[k].Month + "." + abstractClass[i].TheseList[j].AuthorList[k].Year);

}

}

}

Console.WriteLine("Дані збережено у файл " + nameOfFile + ".txt");

Console.WriteLine("Шлях до файлу " + path + nameOfFile + ".txt");

}

catch (Exception ex)

{

Console.WriteLine(ex.Message);

}

finally

{

if (file != null)

file.Close();

}

}

public static void ReadFile()

{

string nameOfFile;

string path = @"D:\";

Console.Write("Введiть назву файлу: ");

nameOfFile = Console.ReadLine();

System.IO.StreamReader file = new System.IO.StreamReader(path + nameOfFile + ".txt");

try

{

Console.WriteLine(file.ReadToEnd());

}

catch (Exception ex)

{

Console.WriteLine(ex.Message);

}

finally

{

if (file != null)

Console.ReadKey();

file.Close();

}

}

public static void WriteBinaryFile(Abstract abstractClass) {

string path = @"D:\fileBin.dat";

SerializeClass ser = new SerializeClass(path,abstractClass);

ser.Serialize();

ser.Close();

}

public static void ReadBinaryFile()

{

string path = @"D:\fileBin.dat";

Abstract buf = null;

Abstract[] abstractClass = null;

//SerializeClass serClass = new SerializeClass(path, buf);

SerializeClass ser = new SerializeClass(path, abstractClass);

buf = (Abstract)ser.Deserialize();

buf.Display();

ser.Close();

}

}

using System.IO;

using System.Runtime.Serialization.Formatters.Binary;

namespace Kurs_2

{

class SerializeClass

{

private object CurrentType = null;

private string CurrentFile = "";

FileStream FS;

//s - Имя файла. t - объект, который надо сериализировать.

public SerializeClass(string s, object t)

{

CurrentType = t;

CurrentFile = s;

}

public void Serialize()

{

FS = new FileStream(CurrentFile,

FileMode.Create, FileAccess.Write, FileShare.ReadWrite);

BinaryFormatter bf = new BinaryFormatter();

bf.Serialize(FS, CurrentType);

FS.Close();

}

public object Deserialize()

{

object a1;

FS = new FileStream(CurrentFile,

FileMode.Open, FileAccess.Read, FileShare.Read);

BinaryFormatter bf = new BinaryFormatter();

a1 = bf.Deserialize(FS);

FS.Close();

return a1;

}

public void Close()

{

CurrentType = null;

CurrentFile = "";

}

}

}

}

i

3

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]