protected void Page_Load(object sender, EventArgs e) { ProductCatalog pc = new ProductCatalog(); pc.AddProduct("Radiation Blaster 3000", 150M, "microwave.jpg"); pc.AddProduct("Fruit Ninja", 70M, "mixer.jpg"); pc.AddProduct("Toasty Buns", 20M, "toaster.jpg"); Response.Write(pc.GetCatalogHtml()); TaxableProduct tp = (TaxableProduct)pc.GetHighPricedProduct(); Response.Write("The high priced product is: " + tp.Name + " at a price of $" + tp.TotalPrice); }
protected void Page_Load(object sender, EventArgs e) { ProductCatalog productCatalog = new ProductCatalog(); productCatalog.AddProduct("Microwave", 12, "http://localhost:54097/C-Sharp/microwave.jpg"); productCatalog.AddProduct("Mixer", 120, "http://localhost:54097/C-Sharp/mixer.jpg"); productCatalog.AddProduct("Toaster", 2, "http://localhost:54097/C-Sharp/toaster.jpg"); Response.Write(productCatalog.GetCatalogHtml()); Response.Write("The highest priced item is: " + productCatalog.GetHighPricedProduct().Name + " " + productCatalog.GetHighPricedProduct().Price); }
protected void Page_Load(object sender, EventArgs e) { // populate a new catalog var catalog = new ProductCatalog(); catalog.AddProduct("Nukulizer 1945", 39.99M, "microwave.jpg"); catalog.AddProduct("Sir Mix-a-Lot", 599.99M, "mixer.jpg"); catalog.AddProduct("The Cylon", 1.99M, "toaster.jpg"); // write catalog to screen Response.Write(catalog.GetCatalogHtml()); // write priciest product to screen AS a TaxableProduct TaxableProduct priceyProduct = catalog.GetHighPricedProduct() as TaxableProduct; if (priceyProduct != null) { StringBuilder builder = new StringBuilder(); builder.AppendFormat( "<p>{0} is the most expensive product at {1:C} (including tax), {2:C} (excluding tax).</p>", priceyProduct.Name, priceyProduct.TotalPrice, priceyProduct.Price); Response.Write(builder.ToString()); } }