开发者

C# console application for an Auctioning system, having problem asking for the item name

I managed my original problem i had to add the break; but now the auction asks for the item date start price and reserve but for some reason when i add all this and then go to browse for the item it just says existing auctions : Auction how do i make it display the name, yet again sorry for my "noobishness" but i am getting there :D your all a great help by the way thank you so much

{
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;
    }
cas开发者_JAVA技巧e exit:
    {
        screen.DisplayMessageLine("");
        screen.DisplayMessageLine("System Shutting Down!");
        userExit = true;
        break;
    }
default:
    {
        screen.DisplayMessageLine("");
        screen.DisplayMessageLine("Selection was not recognisable, please try again");
        break;
    }
}


You need to add a break; statement in the end of your first 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;
    }

For the second part of your question (assuming auction has a property called "ItemName"):

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


You are missing a break statement after your first case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜