public int isCompatibleGivesTrade(NewParty party1, NewParty party2)
        {
            int newQty = -1;

            // Checks the condition of both party
            // Returns the new quantity from party iff they are compatible
            if (party1.qty == 0 || party2.qty == 0)
            {
                return(newQty);
            }
            if (party1.a == 0 && party2.a == 0 && party1.range == 0 && party2.range == 0)
            {
                newQty = Math.Min(party1.qty, party2.qty);
            }
            else if (party1.a == 0 && party1.range == 0 && party2.a != 0 && party2.range == 0)
            {
                if (party1.qty >= party2.qty)
                {
                    newQty = party2.qty;
                }
            }
            else if (party1.a != 0 && party1.range == 0 && party2.a == 0 && party2.range == 0)
            {
                if (party2.qty >= party1.qty)
                {
                    newQty = party1.qty;
                }
            }
            else if (party1.a != 0 && party1.range == 0 && party2.a != 0 && party2.range == 0)
            {
                if (party1.qty == party2.qty)
                {
                    newQty = party1.qty;
                }
            }
            else if (party1.a == 0 && party1.range != 0 && party2.a == 0 && party2.range != 0)
            {
                if (party1.qty == party2.qty)
                {
                    newQty = party1.qty;
                }
                else if (party1.range <= party2.range && party1.qty > party2.qty)
                {
                    newQty = party2.qty;
                }
                else if (party2.range <= party1.range && party2.qty > party1.qty)
                {
                    newQty = party1.qty;
                }
                else if (party1.range <= party2.range && party2.qty > party1.qty)
                {
                    newQty = party1.qty;
                }
                else if (party2.range <= party1.range && party1.qty > party2.qty)
                {
                    newQty = party2.qty;
                }
                else if (party1.qty < party2.qty)
                {
                    newQty = party1.qty;
                }
                else
                {
                    newQty = party2.qty;
                }
            }
            else if (party1.a == 0 && party1.range == 0 && party2.a == 0 && party2.range != 0)
            {
                if (party1.qty >= party2.range && party1.qty <= party2.qty)
                {
                    newQty = party1.qty;
                }
                else if (party1.qty >= party2.qty)
                {
                    newQty = party2.qty;
                }
            }
            else if (party2.a == 0 && party2.range == 0 && party1.a == 0 && party1.range != 0)
            {
                if (party2.qty >= party1.range && party2.qty <= party1.qty)
                {
                    newQty = party2.qty;
                }
                else if (party2.qty >= party1.qty)
                {
                    newQty = party1.qty;
                }
            }
            else if (party1.a != 0 && party1.range == 0 && party2.a == 0 && party2.range != 0)
            {
                if (party1.qty >= party2.range && party1.qty <= party2.qty)
                {
                    newQty = party1.qty;
                }
            }
            else if (party2.a != 0 && party2.range == 0 && party1.a == 0 && party1.range != 0)
            {
                if (party2.qty >= party1.range && party2.qty <= party1.qty)
                {
                    newQty = party2.qty;
                }
            }
            else if (party1.a != 0 && party1.range == 0 && party2.a != 0 && party2.range != 0)
            {
                if (party1.qty == party2.qty)
                {
                    newQty = party1.qty;
                }
            }
            else if (party2.a != 0 && party2.range == 0 && party1.a != 0 && party1.range != 0)
            {
                if (party1.qty == party2.qty)
                {
                    newQty = party2.qty;
                }
            }
            else if (party1.a == 0 && party1.range == 0 && party2.a != 0 && party2.range != 0)
            {
                if (party1.qty >= party2.qty)
                {
                    newQty = party2.qty;
                }
            }
            else if (party2.a == 0 && party2.range == 0 && party1.a != 0 && party1.range != 0)
            {
                if (party2.qty >= party1.qty)
                {
                    newQty = party1.qty;
                }
            }
            else if (party1.a != 0 && party1.range != 0 && party2.a == 0 && party2.range != 0)
            {
                if (party1.qty == party2.qty)
                {
                    newQty = party2.qty;
                }
                else if (party1.qty == party2.range)
                {
                    newQty = party1.qty;
                }
            }
            else if (party2.a != 0 && party2.range != 0 && party1.a == 0 && party1.range != 0)
            {
                if (party2.qty == party1.qty)
                {
                    newQty = party1.qty;
                }
                else if (party2.qty == party1.range)
                {
                    newQty = party2.qty;
                }
            }
            else
            {
                if (party1.qty == party2.qty)
                {
                    newQty = party1.qty;
                }
            }
            return(newQty);
        }
 public void updateQty(NewParty partyA, NewParty partyB, int trade)
 {
     partyA.qty -= trade;
     partyB.qty -= trade;
 }