Esempio n. 1
0
    private static void Main()
    {
        string line;

        while ((line = Console.ReadLine()) != null)
        {
            Console.WriteLine(
                COINS.Solve(int.Parse(line)));
        }
    }
Esempio n. 2
0
 public long GetOrCreateCoinId(long serialNumber)
 {
     try
     {
         using (var context = new GritCoinEntities())
         {
             var COIN = context.COINS.FirstOrDefault(CO => CO.SERIAL_NUMBER == serialNumber);
             if (COIN == null)
             {
                 COIN = new COINS
                 {
                     GRITCOIN_ID   = GetSequenceNextValue(context, "GRITCOIN.COINS_SEQ"),
                     SERIAL_NUMBER = serialNumber
                 };
                 context.AddToCOINS(COIN);
                 context.SaveChanges();
             }
             return(COIN.GRITCOIN_ID);
         }
     }
     catch { throw; }
 }
Esempio n. 3
0
 public static void SetPlayerInfo()
 {
     for (int count = 0; count < numOfPlayers; count++)
     {
         LIVES.Add(HotDAMN.INITIAL_LIVES_COUNT);
         COINS.Add(0);
         SCORE.Add(0);
         worldNum.Add(HotDAMN.INITIAL_WORLD_NUMBER);
         levelNum.Add(HotDAMN.INITIAL_LEVEL_NUMBER);
         midpointHit.Add(false);
         MARIO_STATE.Add(null);
         firstLevelEntrance.Add(true);
         if (count == 1)
         {
             playerName.Add("LUIGI");
         }
         else
         {
             playerName.Add("MARIO");
         }
     }
 }
        public string GetSurrender()
        {
            int  more;
            byte C1  = 0;
            byte C2  = 0;
            byte C5  = 0;
            byte C10 = 0;

            while (Startup.balance.GetBalance() > 0)
            {
                more = 0;
                COINS C = COINS.Undefined;
                if (coins.Coin_1 > more)
                {
                    more = coins.Coin_1;
                    C    = COINS.Coin_1;
                }
                if (coins.Coin_2 > more)
                {
                    more = coins.Coin_2;
                    C    = COINS.Coin_2;
                }
                if (coins.Coin_5 > more)
                {
                    more = coins.Coin_5;
                    C    = COINS.Coin_5;
                }
                if (coins.Coin_10 > more)
                {
                    more = coins.Coin_10;
                    C    = COINS.Coin_10;
                }

                switch (C)
                {
                case COINS.Coin_1:
                    if (TakeBalance(1))
                    {
                        coins.Coin_1--;
                        C1++;
                    }
                    break;

                case COINS.Coin_2:
                    if (TakeBalance(2))
                    {
                        coins.Coin_2--;
                        C2++;
                    }
                    break;

                case COINS.Coin_5:
                    if (TakeBalance(5))
                    {
                        coins.Coin_5--;
                        C5++;
                    }
                    break;

                case COINS.Coin_10:
                    if (TakeBalance(10))
                    {
                        coins.Coin_10--;
                        C10++;
                    }
                    break;

                default:
                    return("Error");
                }

                if (Startup.balance.GetBalance() == 1)
                {
                    TakeBalance(1);
                    coins.Coin_1--;
                    C1++;
                }
                else if (Startup.balance.GetBalance() == 2)
                {
                    TakeBalance(2);
                    coins.Coin_2--;
                    C2++;
                }
                else if (Startup.balance.GetBalance() == 3)
                {
                    TakeBalance(1);
                    coins.Coin_1--;
                    C1++;
                    TakeBalance(2);
                    coins.Coin_2--;
                    C2++;
                }
                else if (Startup.balance.GetBalance() == 4)
                {
                    TakeBalance(2);
                    coins.Coin_2--;
                    C2++;
                    TakeBalance(2);
                    coins.Coin_2--;
                    C2++;
                }
                else if (Startup.balance.GetBalance() == 5)
                {
                    TakeBalance(5);
                    coins.Coin_5--;
                    C5++;
                }
            }
            return(C1 + "_" + C2 + "_" + C5 + "_" + C10);
        }