internal static BookInfo UpdateBook(BookInfo bk) { // Discounts the price of all // computer books by 20 percent. string paramId = bk.Id; string paramAuthor = bk.Author; string paramTitle = bk.Title; string paramGenre = bk.Genre; string paramPrice = bk.Price; if (paramGenre.ToLower() == "computer") { double oldprice = Convert.ToDouble(paramPrice); double newprice = oldprice - oldprice * .20; paramPrice = newprice.ToString(); if (paramPrice.IndexOf(".") == paramPrice.Length - 4) { paramPrice = paramPrice.Substring(1, paramPrice.Length - 1); } Console.WriteLine("{0} - Old Price: {1}, New Price: {2}", paramTitle, oldprice, paramPrice); } string paramPublishDate = bk.PublishDate; string paramDescription = bk.Description; BookInfo bookUpdated = new MyBookInfo(paramId, paramAuthor, paramTitle, paramGenre, paramPrice, paramPublishDate, paramDescription); return(bookUpdated); }
// Populate a BookInfo object with data // about the best selling book. public override BookInfo GetBestSeller() { var paramId = "bk999"; var paramAuthor = "Corets, Eva"; var paramTitle = "Cooking with Oberon"; var paramGenre = "Cooking"; var paramPrice = "7.95"; var paramPublishDate = "2006-12-01"; var paramDescription = "Recipes for a post-apocalyptic society."; var bestBook = new MyBookInfo(paramId, paramAuthor, paramTitle, paramGenre, paramPrice, paramPublishDate, paramDescription); return(bestBook); }