visual studio 2010 -用于拍卖系统的c#控制台应用程序,在询问物品名称时遇到问题

本文关键字:问题 遇到 应用程序 用于 2010 studio 拍卖 系统 控制台 visual | 更新日期: 2023-09-27 17:49:22

我解决了原来的问题,我不得不添加break;但现在拍卖要求项目日期,开始价格和保留,但出于某种原因,当我添加所有这些,然后去浏览项目,它只是说现有的拍卖:拍卖我如何让它显示名称,再次为我的"笨拙"感到抱歉,但我正在那里:D你所有的一个伟大的帮助,顺便说一下,谢谢你这么多

{
case place_auction:
    {
        screen.DisplayMessage("Please Enter a title for your Auction Item");
        string ItemName = Convert.ToString(Console.ReadLine());
        screen.DisplayMessage("Enter a start price for your item:");
        double startPrice = Convert.ToDouble(Console.ReadLine());
        screen.DisplayMessage("Now enter your reserve price for your item:");
        double reservePrice = Convert.ToDouble(Console.ReadLine());
        screen.DisplayMessage("Enter the closing date for your auction:");
        DateTime closeDate = Convert.ToDateTime(Console.ReadLine());
        // creating the auction
        Auction aucttion = new Auction(ItemName, startPrice, reservePrice, closeDate);
        // auction is entering auction list.
        auctionList.Add(aucttion);
        Console.WriteLine("auction is now created :)");
        Console.WriteLine("Auction details are as follows:");
        Console.WriteLine("Item name" + ItemName);
        Console.WriteLine("The Starting Price" + startPrice);
        Console.WriteLine("The Reserve Price" + reservePrice);
        Console.WriteLine("Closing date of this auction" + closeDate);
    }
case browse_auction:
    {
        if (auctionList.Count > 0)
        {
            Console.WriteLine("Existing Auctions:");
            foreach (Auction aucttion in auctionList)
            {
                Console.WriteLine("Auction");
            }
        }
        else
        {
            Console.WriteLine(" No existing auction appearing on the system");
        }
        break;
    }
case locate_auction:
    {
        screen.DisplayMessageLine("Insert Auction ID: ");
        break;
    }
case exit:
    {
        screen.DisplayMessageLine("");
        screen.DisplayMessageLine("System Shutting Down!");
        userExit = true;
        break;
    }
default:
    {
        screen.DisplayMessageLine("");
        screen.DisplayMessageLine("Selection was not recognisable, please try again");
        break;
    }
}

visual studio 2010 -用于拍卖系统的c#控制台应用程序,在询问物品名称时遇到问题

你需要添加一个break;语句,在第一个case的末尾:

case place_auction:
    {
        /* snipped */
        Console.WriteLine("The Starting Price" + startPrice);
        Console.WriteLine("The Reserve Price" + reservePrice);
        Console.WriteLine("Closing date of this auction" + closeDate);
        break;
    }

对于问题的第二部分(假设auction有一个名为"ItemName"的属性):

    Console.WriteLine(string.Format("Auction: {0}", auction.ItemName));

在第一个case之后缺少break语句