Beispiel #1
0
        public void TestMethod2()
        {
            foreach (OffNovelBook book in BookStore2.BookList)
            {
                NovelBook novelBook = book;
                Debug.WriteLine("书名: " + novelBook.GetName());
                Debug.WriteLine("作者: " + novelBook.GetAuthor());
                Debug.WriteLine("原价: " + novelBook.GetPrice());

                OffNovelBook offNovelBook = book;
                Debug.WriteLine("打折价: " + offNovelBook.GetPrice());
            }
            //运行结果:
            //书名: 书1
            //作者: 作者
            //原价: 24
            //打折价: 19.2
            //书名: 书2
            //作者: 作者2
            //原价: 60
            //打折价: 54
            //书名: 书3
            //作者: 作者3
            //原价: 99
            //打折价: 89.1
        }
Beispiel #2
0
 public void TestMethod1()
 {
     foreach (NovelBook book in BookStore.BookList)
     {
         NovelBook novelBook = book;
         Debug.WriteLine("书名: " + novelBook.GetName());
         Debug.WriteLine("作者: " + novelBook.GetAuthor());
         Debug.WriteLine("原价: " + novelBook.GetPrice());
     }
 }
        public new int GetPrice()
        {
            //原价
            int selfPrice = novelBook.GetPrice();
            int offPrice  = 0;

            if (selfPrice > 4000)
            {
                //原价大于40元,则打9折
                offPrice = selfPrice * 50 / 100;
            }
            else
            {
                offPrice = selfPrice * 20 / 100;
            }
            return(offPrice);
        }