static void Main(string[] args) { var cart1 = new ShoppingCart(); var banana = new ShoppingCartItem() { Name = "Bananas", Price = 2.25m }; var beanie = new ShoppingCartItem() { Name = "Beanie Baby", Price = 12.34m }; var ps3 = new ShoppingCartItem() { Name = "PS3", Price = 150.99m }; banana.Id = cart1.AddItem(banana); beanie.Id = cart1.AddItem(beanie); ps3.Id = cart1.AddItem(ps3); cart1.RemoveItem(3); cart1.ListItems(); Debug.Assert(cart1.AddItem(new ShoppingCartItem { Name = "dlk", Price = 3.2m }) == 3, "This is not the 3rd index"); Debug.Assert(cart1.RemoveItem(1) == true, "There is no cart1 item 1"); Debug.Assert(cart1.ListItems() == 3, "There aren't 3 items here"); Console.ReadLine(); }
static void Main(string[] args) { ShoppingCart WalmartCart = new ShoppingCart(); WalmartCart.AddItem("Milk", 2.30m); WalmartCart.AddItem("Eggs", 0.99m); WalmartCart.AddItem("Bread", 3.89m); WalmartCart.AddItem("Lettuce", 0.70m); WalmartCart.ListItems(); Console.WriteLine(); Console.WriteLine("Enter the ID# of the item you'd like to remove."); WalmartCart.RemoveItem(int.Parse(Console.ReadLine())); WalmartCart.AddItem("Wine", 25.99m); Console.WriteLine(); WalmartCart.ListItems(); Console.ReadLine(); //pause }
static void Main(string[] args) { //var cart = new ArrayList(); //ShoppingCart.AddItem("Hat", 1234, 2.99m); //ShoppingCart.AddItem("Cat", 4321, 100.00m); //ShoppingCart.AddItem("Bat", 9876, 5.00m); ShoppingCart.AddItem(ShoppingCartItem); Console.WriteLine("Your cart contains"); //ShoppingCart.ListItems(cart); Console.ReadLine(); }