Пример #1
0
    public static void Main(string[] args)
    {
        // Top level todo list:
        TaskList todo = new TaskList("To-Do for today:");

        // List for groceries:
        TaskList groceries = new TaskList("Go to the store:");

        groceries.AddToList(new ListItem("Apples"));
        groceries.AddToList(new ListItem("Bread"));
        groceries.AddToList(new ListItem("Yogurt"));
        groceries.AddToList(new ListItem("Popcorn"));

        // Add list to the top level:
        todo.AddToList(groceries);

        // Homework list:
        TaskList homework = new TaskList("Do my homework:");

        homework.AddToList(new ListItem("Math paper"));
        homework.AddToList(new ListItem("Physics quiz"));
        // CS sub-list:
        TaskList csHomework = new TaskList("CSC:");

        csHomework.AddToList(new ListItem("Lab"));
        csHomework.AddToList(new ListItem("Assignment"));
        csHomework.AddToList(new ListItem("Make flashcards"));
        // Add CS list to homework list:
        homework.AddToList(csHomework);
        // Add homework list to top level:
        todo.AddToList(homework);

        // Read off the list:
        todo.Read();

        Console.WriteLine("Done");

        /*
         *  Output:
         *
         *  To-Do for today:
         *      Go to the store:
         *          Apples
         *          Bread
         *          Yogurt
         *          Popcorn
         *      Do my homework:
         *          Math paper
         *          Physics quiz
         *          CSC:
         *          Lab
         *          Assignment
         *          Make flashcards
         *  Done
         */
    }