コード例 #1
0
        static void Main()
        {
            Book book = new Book("Ernest Hemingway", "For Whom the Bell Tolls", 100, 480);

            Song song = new Song("Metallica", "For Whom the Bell Tolls", 120, 5.12);

            book.Display();
            song.Display();

            Console.WriteLine("-----------------------------------------");
            Console.WriteLine("Make the book and song borrowable and three books borrowed");
            Borrowable borrowableBook = new Borrowable(book);
            Borrowable borrowableSong = new Borrowable(song);

            borrowableBook.BorrowItem("Marin Marinov");
            borrowableBook.BorrowItem("Ivan Ivanov");
            borrowableBook.BorrowItem("Dimitar Dimitrov");
            borrowableBook.Display();

            Console.WriteLine("-----------------------------------------");
            Console.WriteLine("Two books returned");
            borrowableBook.ReturnItem("Marin Marinov");
            borrowableBook.ReturnItem("Ivan Ivanov");
            borrowableBook.Display();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Beverage essp = new Espresso();

            Console.WriteLine(essp.GetDiscription() + "\t" + essp.cost().ToString());

            Beverage houseB = new HouseBlend();

            Console.WriteLine(houseB.GetDiscription() + "\t" + houseB.cost().ToString());

            essp = new Whip(essp);
            Console.WriteLine(essp.GetDiscription() + "\t" + essp.cost().ToString());

            essp = new SteamMilk(essp);
            Console.WriteLine(essp.GetDiscription() + "\t" + essp.cost().ToString());

            houseB = new Soy(houseB);
            Console.WriteLine(houseB.GetDiscription() + "\t" + houseB.cost().ToString());

            // Create book
            Book book = new Book("Worley", "Inside ASP.NET", 10);

            book.Display();
            // Create video
            Video video = new Video("Spielberg", "Jaws", 23, 92);

            video.Display();
            // Make video borrowable, then borrow and display

            Console.WriteLine("\nMaking video borrowable:");

            Borrowable borrowvideo = new Borrowable(video);

            borrowvideo.BorrowItem("Customer #1");
            borrowvideo.BorrowItem("Customer #2");
            borrowvideo.BorrowItem("Customer #3");
            borrowvideo.Display();

            borrowvideo.ReturnItem("Customer #1");
            borrowvideo.ReturnItem("Customer #2");
            borrowvideo.Display();

            // Wait for user
            Console.ReadKey();

            while (true)
            {
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Paulmcl78/PatternPractice
        static void Main(string[] args)
        {
            //create book
            Book book = new Book("Worley","Inside ASP.NET",10);
            book.Display();

            //create video
            Video video = new Video("Spielberg","Jaws",23,92);
            video.Display();

            //Make a video borrowable, then borrow and display

            Console.WriteLine("\nMaking video borrowable");

            Borrowable borrowvideo = new Borrowable(video);
            borrowvideo.BorrowItem("Joe Bloggs");
            borrowvideo.BorrowItem("Homer Simpson");

            borrowvideo.Display();

            Console.WriteLine("\nJoe Bloggs returns video");

            // return a vidoe and display - notice video count
            borrowvideo.ReturnItem("Joe Bloggs");
            borrowvideo.Display();

            //wait for user
            Console.ReadKey(true);
        }
コード例 #4
0
        public void ReturnItemTest()
        {
            borrowableVideo.Borrowers.Add(customer);

            int initialAvailableCopies = video.NumCopies;

            borrowableVideo.ReturnItem(customer);

            Assert.AreEqual(initialAvailableCopies + 1, video.NumCopies);
            CollectionAssert.DoesNotContain(borrowableVideo.Borrowers, customer);
        }