Ejemplo n.º 1
0
        public void Run()
        {
            PostDatabase  db       = new PostDatabase();
            List <string> newPosts = new List <string>();

            newPosts.Add("original post");
            newPosts.Add("#tag post");
            newPosts.Add("@mention post");

            Post postObj;

            foreach (string post in newPosts)
            {
                if (post.StartsWith("#"))
                {
                    postObj = new TagPost();
                }
                else if (post.StartsWith("@"))
                {
                    postObj = new MentionPost();
                }
                else
                {
                    postObj = new Post();
                }

                // The issue here is that the create post will implement the code on Post but not other!
                string result = postObj.CreatePost(db, post);
                Console.WriteLine(result);
            }
        }
Ejemplo n.º 2
0
 public string CreateMentionPost(PostDatabase db, string post)
 {
     return(db.AddMentionPost(post));
 }
Ejemplo n.º 3
0
 public virtual string CreatePost(PostDatabase db, string post)
 {
     return(db.Add(post));
 }
Ejemplo n.º 4
0
 public string CreateTagPost(PostDatabase db, string post)
 {
     return(db.AddTagPost(post));
 }