Консольное приложение C # для Аукционной системы, возникла проблема с запросом имени элемента - PullRequest
0 голосов
/ 06 апреля 2011

Я справился со своей первоначальной проблемой, мне пришлось добавить разрыв; но теперь аукцион запрашивает начальную цену и запас по дате товара, но по какой-то причине, когда я добавляю все это, а затем иду, чтобы найти предмет, он просто говорит существующие аукционы: Аукцион как мне заставить его отображать имя, еще раз извиняюсь за мою "нубишность", но я добираюсь до этого: 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;
    }
}

Ответы [ 2 ]

1 голос
/ 06 апреля 2011

Вам нужно добавить перерыв; заявление в конце вашего первого дела:

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;
    }

Для второй части вашего вопроса (при условии, что аукцион имеет свойство с именем "ItemName"):

    Console.WriteLine(string.Format("Auction: {0}", auction.ItemName));
0 голосов
/ 06 апреля 2011

Вы пропустили оператор break после первого случая.

...