Untitled

 avatar
unknown
csharp
a year ago
3.5 kB
6
Indexable
public class Programm
{
    //dokument
    //avtor
    //Data sozdaniya
    //Data izmeneniya
    //zagalovok
    //soderjimoe

    //- Глава -
    //Назввание
    //Документы

    //Документация
    //1. Инструкция
    //2. Начало

    public static void Main(string[] args)
    {
        Chapter[] testChapters = new Chapter[]
        {
            new Chapter("Введение", new Document []
            {
                new Document("Alemkhan", "Информация о документах","Тут будет информация о документах"),
                new Document("Alemkhan", "Об авторе", "Тут информация про Автора")
            }),
            new Chapter("Как начать", new Document[]
            {
                new Document("Alemkhan", "Инструкция по установке", "Тут все про установку"),
                new Document("Alemkhan", "Требование", "Тут требованиея для установки"),
                new Document("Alemkhan", "Возможные проблемы", "Тут будет все возможные проблемы при установке")
            }),
            new Chapter("Расширение", new Document[]
            {
                new Document("Alemkhan","Как пользоваться расширением", "Тут будет инструкция по расширению")
            })
        };

        Document testDocument = new Document("Alemkhan", "TestTitle", "Test Content for Test Title by Alemkhan");

        for (int i = 0; i < testChapters.Length; i++)
        {
            Console.WriteLine($"{i + 1}. {testChapters[i].Name}");
        }
        Console.WriteLine();
        Console.WriteLine($"Please select the chapter between 1 and {testChapters.Length}");

        int selectTheChapter = Convert.ToInt32(Console.ReadLine())-1;

        if (selectTheChapter < 1 || selectTheChapter>testChapters.Length)
        {
            Console.WriteLine("Chapter you have selected does not exist");
        }
        if(selectTheChapter>0||selectTheChapter<testChapters.Length)
        {
            for (int i = 0; i < testChapters[selectTheChapter].Documents.Length; i++)
            {
                Console.WriteLine($"{i + 1}. {testChapters[selectTheChapter].Documents[i].Title}");
            }
        }
    }
}

class Document
{
    public string Author;
    public DateTime CreatedDate;
    public DateTime UpdatedDate;
    public string Title;
    public string Content;

    public Document(string author, string title, string content)
    {
        Author = author;
        Title = title;
        Content = content;
        CreatedDate = DateTime.Now;
        UpdatedDate = CreatedDate;
    }

    public void Print()
    {
        Console.WriteLine($"Author:{Author}");
        Console.WriteLine($"Created Date:{CreatedDate}");
        Console.WriteLine($"Updated Date:{UpdatedDate}");
        Console.WriteLine();
        Console.WriteLine($"Title:{Title}");
        Console.WriteLine($"Content:\n\t{Content}");
    }
}

class Chapter
{
    public string Name;
    public Document[] Documents;

    public Chapter(string name, Document[] documents)
    {
        Name = name;
        Documents = documents;
    }
}
Leave a Comment