Esempio n. 1
0
        public void consoleWorks()
        {
            Buyers  myBuyers  = new Buyers();
            Sellers mySellers = new Sellers();
            int     input     = default(int);
            int     qty       = 0;
            int     a         = 0;
            int     r         = 0;
            char    readI     = default(char);

            while (readI != 'q')
            {
                Console.WriteLine("Enter -999 to Stop");
                Console.WriteLine("Buyers:");
                while (input != -999)
                {
                    String choice, uid;
                    Console.WriteLine(" Is Parent or Child: Enter P for Parent and C for Child");
                    choice = Console.ReadLine();
                    if (choice == "C")
                    {
                        Console.WriteLine(" Enter Parent Node UserId: ");
                        uid = Console.ReadLine();
                    }
                    else
                    {
                        Console.WriteLine("Enter UserId");
                        uid = Console.ReadLine();
                        Console.WriteLine("Enter 1 for ALL or Nothing Condition ,0 for nothing");
                        a = Int32.Parse(Console.ReadLine());
                        Console.WriteLine("Enter Ticket Size");
                        r = Int32.Parse(Console.ReadLine());
                    }
                    Console.WriteLine("Enter Qty");
                    qty = Int32.Parse(Console.ReadLine());
                    NewPartyWithId myNewParty = new NewPartyWithId(qty, a, r, uid);
                    if (choice == "C")
                    {
                        myBuyers.addChild(uid, myNewParty);
                    }
                    else
                    {
                        myBuyers.addBuyers(myNewParty);
                    }
                    Console.WriteLine("Enter -999 to Stop,anyother number to continue");
                    input = Int32.Parse(Console.ReadLine());
                }
                Console.WriteLine("Sellers:");
                input = 0;
                while (input != -999)
                {
                    Console.WriteLine("Enter -999 to Stop");
                    Console.WriteLine("Sellers:");
                    while (input != -999)
                    {
                        String choice, uid;
                        Console.WriteLine(" Is Parent or Child: Enter P for Parent and C for Child");
                        choice = Console.ReadLine();
                        if (choice == "C")
                        {
                            Console.WriteLine(" Enter Parent Node UserId: ");
                            uid = Console.ReadLine();
                        }
                        else
                        {
                            Console.WriteLine("Enter UserId");
                            uid = Console.ReadLine();
                            Console.WriteLine("Enter 1 for ALL or Nothing Condition ,0 for nothing");
                            a = Int32.Parse(Console.ReadLine());
                            Console.WriteLine("Enter Ticket Size");
                            r = Int32.Parse(Console.ReadLine());
                        }
                        Console.WriteLine("Enter Qty");
                        qty = Int32.Parse(Console.ReadLine());
                        NewPartyWithId myNewParty = new NewPartyWithId(qty, a, r, uid);
                        if (choice == "C")
                        {
                            mySellers.addChild(uid, myNewParty);
                        }
                        else
                        {
                            mySellers.addSellers(myNewParty);
                        }
                        Console.WriteLine("Enter -999 to Stop,any other number to continue");
                        input = Int32.Parse(Console.ReadLine());
                    }
                    Buyers  myCopyBuyers  = new Buyers();
                    Sellers myCopySellers = new Sellers();
                    myCopyBuyers.setBuyers(myBuyers.getCopyBuyers());
                    myCopySellers.setSellers(mySellers.getCopySellers());
                    myBuyers.printBuyers();
                    mySellers.printSellers();
                    Console.WriteLine(" --- Actual Result ---");
                    solve(myBuyers, mySellers);
                    Console.WriteLine(" --- Reverse Result ---");
                    solve(myCopyBuyers, myCopySellers);
                    readI = (char)Console.ReadLine().ToCharArray()[0];
                }
            }
        }