コード例 #1
0
        static void Main(string[] args)
        {
            // In a real world example the string below would be pulled from the inputfield of course...
            Console.WriteLine("Title..:");
            var title = Console.ReadLine();

            Console.WriteLine("Post..:");
            var post = new Post(title, Console.ReadLine());

            // 7 Upvotes...
            for (int i = 1; i <= 7; i++)
            {
                post.Upvote();
            }

            // And 3 Downvotes...
            for (int i = 1; i <= 3; i++)
            {
                post.DownVote();
            }

            Console.WriteLine("Post | ({0}) | \"{1}\" [score: {2}]", post.PostTitle, post.PostContent, post.PostScore);
            Console.ReadKey(true);

            // Here comes reddit! 300 downvotes...
            for (int i = 1; i <= 300; i++)
            {
                post.DownVote();
            }

            // Udemy to the rescue (500 votes!)...
            for (int i = 1; i <= 500; i++)
            {
                post.Upvote();
            }

            Console.WriteLine("Post | ({0}) | \"{1}\" [score: {2}]", post.PostTitle, post.PostContent, post.PostScore);
            Console.ReadKey(true);

            // In the real world there would be an input field for the user to edit the post. We assume this method
            // Would then take the new version of the post and insert it as a new string.
            // Note that this OP is not a nice human as he didn't post the fix!!!
            post.EditPost("Solved - Please close", "Edit: I fixed this now please close the post...");

            Console.WriteLine("Post | ({0}) | \"{1}\" [score: {2}]", post.PostTitle, post.PostContent, post.PostScore);
            Console.ReadKey(true);

            // Downvoted to oblivion for bad internet manners.
            for (int i = 1; i <= 4124; i++)
            {
                post.DownVote();
            }

            Console.WriteLine("Post | ({0}) | \"{1}\" [score: {2}]", post.PostTitle, post.PostContent, post.PostScore);
            Console.ReadKey(true);
        }