Beispiel #1
0
 public override void addAuction(Auction newAuc)
 {
     newAuc = new Auction(" ");
     myAuctions.Add(newAuc);
 }
Beispiel #2
0
 public override void addAuction(Auction newAuc)
 {
     // Console.WriteLine("Buyer cannot create auction");
 }
Beispiel #3
0
 public void placeAuction(Auction newAuc)
 {
     Auctions.Add(newAuc);
 }
Beispiel #4
0
        //-------PUBLIC METHODS---------------------

        /// <summary>
        ///  This function is used to run our auction.
        /// </summary>
        ///  <remarks>
        ///  Run the application loop
        /// </remarks>
        public void run()
        {
            //variables to hold our user menu choice
            string userInput;
            int    choice;
            int    exit = 5;
            // --------------- Sample Auctions ------------------------------------------
            Auction test;

            test = new Auction("Test");
            placeAuction(test);
            test.setCurrentPrice(99.99);
            test.setReservePrice(250);
            test.setCloseDate(DateTime.Now.AddSeconds(30));
            test.setIsRunning(true);

            Auction car;

            car = new Auction("car");
            car.setCurrentPrice(2000.99);
            car.setCloseDate(DateTime.Now.AddMinutes(7));
            car.setIsRunning(true);
            car.setReservePrice(3000);
            placeAuction(car);

            Auction laptop;

            laptop = new Auction("Laptop", 100, 300);
            laptop.setCloseDate(DateTime.Now.AddMinutes(2));
            laptop.setIsRunning(true);
            laptop.setCurrentPrice(laptop.getStartPrice());
            placeAuction(laptop);

            Auction ipad;

            ipad = new Auction("ipad", 150, 300, DateTime.Now.AddMinutes(3), true);
            ipad.setCurrentPrice(ipad.getStartPrice());
            placeAuction(ipad);

            //create a thread to automatically close auctions
            Thread checkAuctions = new Thread(threadedCheckAucClose);

            checkAuctions.Start();

            //------------------------------------------------------
            do
            {
                //load the menu and sample data and wait for user response
                Console.ResetColor();
                //Console.Clear();

                currentUser();
                createSampleUser();
                displayMenu();
                userInput = Console.ReadLine();

                //Handles format exception if user enters invalid characters
                if (!Int32.TryParse(userInput, out choice) || choice > 6)
                {
                    Console.WriteLine("Please enter valid input.");
                }
                else
                {
                    choice = Int32.Parse(userInput);
                }

                switch (choice)
                {
                case 1:
                    logIn();
                    break;

                case 2:
                    createUser();
                    break;

                case 3:
                    browseAuction();
                    break;

                case 4:
                    if (tcurrent == null)
                    {
                        break;
                    }
                    if (tcurrent.isLoggedIn() == true)     // only show this menu if user is logged in
                    {
                        createAuction();
                    }
                    break;

                case 5:
                    Environment.Exit(0);
                    break;

                case 6:
                    if (tcurrent.isLoggedIn() == true)     // log off user
                    {
                        tcurrent.setLoggedIn(false);
                    }
                    break;
                }
            } while (choice != exit);
        }
 public abstract void addAuction(Auction newAuc);