Exemplo n.º 1
0
        static void Main(string[] args) {
            // 8) declare 2 objects. Use default and paremeter constructors
            LibraryUser unnamed = new LibraryUser();
            LibraryUser user1 = new LibraryUser("Mike", "Tyson", 100);

            // 9) do operations with books for all users: run all methods for both objects
            unnamed.AddBook("Some book 1");
            Console.WriteLine("User \"Unnamed\" - "+unnamed.ToString());
            Console.WriteLine("Using indexers - "+unnamed[0]);
            Console.WriteLine("Using BookInfo -"+unnamed.BookInfo(0));
            Console.WriteLine("Book count - "+unnamed.BookCount());
            unnamed.RemoveBook("Some book 1");
            Console.WriteLine("Book count after removing the one - "+unnamed.BookCount());
            Console.WriteLine();

            user1.AddBook("Some book 1");
            user1.AddBook("Some book 2");
            user1.AddBook("Some book 3");

            Console.WriteLine("User \"User1\" - " + user1.ToString());
            Console.WriteLine("Using indexers - " + user1[1]);
            Console.WriteLine("Using BookInfo -" + user1.BookInfo(1));
            Console.WriteLine("Book count - " + user1.BookCount());
            user1.RemoveBook("Some book 1");
            Console.WriteLine("Book count after removing the one - " + user1.BookCount());
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // 8) declare 2 objects. Use default and paremeter constructors
            LibraryUser user1 = new LibraryUser(), user2 = new LibraryUser("Maria", "Ivanenko", 155, "+380447777777", 2);

            Console.WriteLine("User1 " + user1.FirstName + " " + user1.LastName);
            Console.WriteLine("User2 " + user2.FirstName + " " + user2.LastName);

            // 9) do operations with books for all users: run all methods for both objects
            Console.WriteLine("User 1: add Harry Potter");
            user1.AddBook("Harry Potter");
            Console.WriteLine("User 2: add Sherlock Holmes");
            user2.AddBook("Sherlock Holmes");
            Console.WriteLine("user1.BooksCount = " + user1.BooksCount() + "; user2.BooksCount " + user2.BooksCount());
            Console.WriteLine("user2 :");
            Console.WriteLine("Add Kobzar");
            user2.AddBook("Kobzar");
            Console.WriteLine("user2.BooksCount " + user2.BooksCount());
            Console.WriteLine("Add Dorian Gray");
            user2.AddBook("Dorian Gray");
            Console.WriteLine("user2.BooksCount " + user2.BooksCount());
            Console.WriteLine("user2 books " + user2.BookInfo(0) + "\n" + user2.BookInfo(1));
            Console.WriteLine("Remove Sherlock Holmes");
            user2.RemoveBook("Sherlock Holmes");
            Console.WriteLine("user2.BooksCount " + user2.BooksCount());
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            IBook thrillerBook = new ThrillerBook();

            thrillerBook.SetBookInfo(new BookInfo {
                Title = "Thriller Book", Author = "Anton", Description = "Lorem ipsum blabla"
            });
            IBook comedyBook1 = new ComedyBook();

            comedyBook1.SetBookInfo(new BookInfo {
                Title = "Comedy Book1", Author = "Anton2", Description = "kjdfhjl dLorem ipsum blabla"
            });
            IBook comedyBook2 = new ComedyBook();

            comedyBook2.SetBookInfo(new BookInfo {
                Title = "Comedy Book2", Author = "Anton2", Description = "kjdfhjl dLorem ipsum blabla"
            });
            IBook comedyBook3 = new ComedyBook();

            comedyBook3.SetBookInfo(new BookInfo {
                Title = "Comedy Book3", Author = "Anton2", Description = "kjdfhjl dLorem ipsum blabla"
            });
            IBook comedyBook4 = new ComedyBook();

            comedyBook4.SetBookInfo(new BookInfo {
                Title = "Comedy Book4", Author = "Anton2", Description = "kjdfhjl dLorem ipsum blabla"
            });

            ILibraryUser libraryUser = new LibraryUser("Anton", "Pluzhnikov", 20, "0937095091");

            libraryUser.AddBook(thrillerBook);
            libraryUser.AddBook(comedyBook1);
            libraryUser.AddBook(comedyBook2);
            libraryUser.AddBook(comedyBook3);
            libraryUser.AddBook(comedyBook4);

            Console.WriteLine(libraryUser);
            Console.ReadLine();

            libraryUser.RemoveBook(comedyBook2);
            Console.WriteLine(libraryUser);
            //Console.ReadLine();

            Console.WriteLine("Please enter index of book to see its info");
            Console.WriteLine(libraryUser[int.Parse(Console.ReadLine())].GetInfo());
            Console.ReadLine();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            // 8) declare 2 objects. Use default and paremeter constructors
            LibraryUser user1 = new LibraryUser();
            LibraryUser user2 = new LibraryUser("name1", "name2", 1, "123456", 10);

            // 9) do operations with books for all users: run all methods for both objects
            user1.AddBook("Book1");
            user1.BookInfo(0);
            user1.BooksCount();
            user1.RemoveBook("Book1");

            user2.AddBook("Book2");
            user2.BookInfo(0);
            user2.BooksCount();
            user2.RemoveBook("Book2");

        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            // 8) declare 2 objects. Use default and paremeter constructors
            LibraryUser libraryUser1 = new LibraryUser("Artem", "Goloborodko","00000001","06765658151", 7);
            LibraryUser libraryUser2 = new LibraryUser();

            // 9) do operations with books for all users: run all methods for both objects
            Console.WriteLine("Program, that simulate library activity");
            Console.WriteLine(new string('*', 70));

            Console.WriteLine("user 1: \nFirstName: {0}, LastName: {1}, ID: {2}, Phone: {3}, BookLimit: {4} ", libraryUser1.FirstName, libraryUser1.LastName, libraryUser1.Id, libraryUser1.Phone, libraryUser1.BookLimit);

            libraryUser1.AddBook("book1");
            libraryUser1.AddBook("book2");
            libraryUser1.AddBook("book4");
            libraryUser1.AddBook("book2");
            libraryUser1.AddBook("book3");

            libraryUser1.RemoveBook("book5");
            libraryUser1.RemoveBook("book4");

            libraryUser1.BookInfo(5);
            libraryUser1.BookInfo(1);

            Console.WriteLine("BooksCount :{0}", libraryUser1.BooksCount());

            Console.WriteLine(new string('*', 70));

            Console.WriteLine("user 2: \nFirstName: {0}, LastName: {1}, ID: {2}, Phone: {3}, BookLimit: {4} ", libraryUser2.FirstName, libraryUser2.LastName, libraryUser2.Id, libraryUser2.Phone, libraryUser2.BookLimit);

            libraryUser2.AddBook("book1");
            libraryUser2.AddBook("book2");
            libraryUser2.AddBook("book4");
            libraryUser2.AddBook("book3");
            libraryUser2.AddBook("book6");

            libraryUser2.RemoveBook("book1");

            Console.WriteLine("BooksCount :{0}", libraryUser2.BooksCount());
            ;

            Console.ReadLine();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            // 8) declare 2 objects. Use default and paremeter constructors

            LibraryUser user1 = new LibraryUser("Artem", "Lutsenko", "000000");
            LibraryUser user2 = new LibraryUser();



            // 9) do operations with books for all users: run all methods for both objects
            user1.AddBook(1);
            user1.BookInfo(1);
            user1.BooksCount();
            user1.RemoveBook(1);

            user2.AddBook(1);
            user2.BookInfo(1);
            user2.BooksCount();
            user2.RemoveBook(1);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            // 8) declare 2 objects. Use default and paremeter constructors

            LibraryUser user1 = new LibraryUser("Artem","Lutsenko", "000000");
            LibraryUser user2 = new LibraryUser();

           

            // 9) do operations with books for all users: run all methods for both objects
            user1.AddBook(1);
            user1.BookInfo(1);
            user1.BooksCount();
            user1.RemoveBook(1);

            user2.AddBook(1);
            user2.BookInfo(1);
            user2.BooksCount();
            user2.RemoveBook(1);

        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            // 8) declare 2 objects. Use default and paremeter constructors
            var user1 = new LibraryUser();
            var user2 = new LibraryUser("User2 First Name", "User2 Last Name", "+380500000000", 20, 1);
            // 9) do operations with books for all users: run all methods for both objects
            user1.AddBook(new Book()
            {
                Author = "Andrew Troelsen",
                Name = "Pro C# 5.0 and the .NET 4.5 Framework (Expert's Voice in .NET) 6th ed. 2012 Edition",
                Year = 2012,
                PublishingHouse = "Apres",
                PageCount = 1463

            });
            user1.AddBook(new Book()
            {
                Author = "Jeffrey Richter",
                Name = "CLR via C# (4th Edition) (Developer Reference) 4th Edition",
                Year = 2013,
                PublishingHouse = "Microsoft Press",
                PageCount = 823

            });
            foreach (var book in user1.BookList)
            {
                Console.WriteLine(book.ToString());
            }

            Console.WriteLine("user1 book info {0}",user1.BookInfo(1));
            Console.WriteLine("user1 book info {0}",user1.BookInfo(10));
            Console.WriteLine("user2 book info {0}", user1.BookInfo(0));
            Console.WriteLine("user2 book info {0}", user1.BookInfo(10));
            user2.AddBook(new Book()
            {
                Author = "Jeffrey Richter",
                Name = "CLR via C# (4th Edition) (Developer Reference) 4th Edition",
                Year = 2013,
                PublishingHouse = "Microsoft Press",
                PageCount = 823

            });
            user2.AddBook(new Book()
            {
                Author = "Andrew Troelsen",
                Name = "Pro C# 5.0 and the .NET 4.5 Framework (Expert's Voice in .NET) 6th ed. 2012 Edition",
                Year = 2012,
                PublishingHouse = "Apres",
                PageCount = 1463

            });
            foreach (var book in user2.BookList)
            {
                Console.WriteLine(book.ToString());
            }

            Console.WriteLine("user1 books count - {0}",user1.BooksCount());
            Console.WriteLine("user2 books count - {0}", user2.BooksCount());
            user1.RemoveBook(0);
            user2.RemoveBook(1);

            Console.WriteLine("user1 books count - {0}", user1.BooksCount());
            Console.WriteLine("user2 books count - {0}", user2.BooksCount());
            foreach (var book in user1.BookList)
            {
                Console.WriteLine(book.ToString());
            }

            foreach (var book in user2.BookList)
            {
                Console.WriteLine(book.ToString());
            }
            Console.ReadKey();
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            // 8) declare 2 objects. Use default and paremeter constructors
            var user1 = new LibraryUser();
            var user2 = new LibraryUser("User2 First Name", "User2 Last Name", "+380500000000", 20, 1);

            // 9) do operations with books for all users: run all methods for both objects
            user1.AddBook(new Book()
            {
                Author          = "Andrew Troelsen",
                Name            = "Pro C# 5.0 and the .NET 4.5 Framework (Expert's Voice in .NET) 6th ed. 2012 Edition",
                Year            = 2012,
                PublishingHouse = "Apres",
                PageCount       = 1463
            });
            user1.AddBook(new Book()
            {
                Author          = "Jeffrey Richter",
                Name            = "CLR via C# (4th Edition) (Developer Reference) 4th Edition",
                Year            = 2013,
                PublishingHouse = "Microsoft Press",
                PageCount       = 823
            });
            foreach (var book in user1.BookList)
            {
                Console.WriteLine(book.ToString());
            }

            Console.WriteLine("user1 book info {0}", user1.BookInfo(1));
            Console.WriteLine("user1 book info {0}", user1.BookInfo(10));
            Console.WriteLine("user2 book info {0}", user1.BookInfo(0));
            Console.WriteLine("user2 book info {0}", user1.BookInfo(10));
            user2.AddBook(new Book()
            {
                Author          = "Jeffrey Richter",
                Name            = "CLR via C# (4th Edition) (Developer Reference) 4th Edition",
                Year            = 2013,
                PublishingHouse = "Microsoft Press",
                PageCount       = 823
            });
            user2.AddBook(new Book()
            {
                Author          = "Andrew Troelsen",
                Name            = "Pro C# 5.0 and the .NET 4.5 Framework (Expert's Voice in .NET) 6th ed. 2012 Edition",
                Year            = 2012,
                PublishingHouse = "Apres",
                PageCount       = 1463
            });
            foreach (var book in user2.BookList)
            {
                Console.WriteLine(book.ToString());
            }



            Console.WriteLine("user1 books count - {0}", user1.BooksCount());
            Console.WriteLine("user2 books count - {0}", user2.BooksCount());
            user1.RemoveBook(0);
            user2.RemoveBook(1);

            Console.WriteLine("user1 books count - {0}", user1.BooksCount());
            Console.WriteLine("user2 books count - {0}", user2.BooksCount());
            foreach (var book in user1.BookList)
            {
                Console.WriteLine(book.ToString());
            }

            foreach (var book in user2.BookList)
            {
                Console.WriteLine(book.ToString());
            }
            Console.ReadKey();
        }