/// <summary>
        /// Allows for conversion of <see cref="IUnit"/> derived type.
        /// </summary>
        /// <remarks>
        /// Note: the type <typeparamref name="TN1"/> must be a relative of <typeparamref name="T1"/>.
        /// Note: the type <typeparamref name="TN2"/> must be a relative of <typeparamref name="T2"/>.
        /// </remarks>
        /// <typeparam name="TN1">The new type you want to convert the current scalar's type to.</typeparam>
        /// <typeparam name="TN2">The new type you want to convert the current scalar's type to.</typeparam>
        /// <returns>A new scalar with type of <typeparamref name="TN1"/>, <typeparamref name="TN2"/> who's value has been converted to <typeparamref name="TN1"/>, <typeparamref name="TN2"/>.</returns>
        public Scalar <TN1, TN2> To <TN1, TN2>()
            where TN1 : class, IUnit, new()
            where TN2 : class, IUnit, new()
        {
            TN1 newUnit1 = new TN1();
            TN2 newUnit2 = new TN2();

            foreach (Type t in Unit1.GetType().GetInterfaces())
            {
                if (newUnit1.GetType().GetInterface(t.Name) == null)
                {
                    throw new InvalidCastException(String.Format(CultureInfo.CurrentCulture, "You cannot convert {0} to {1}", Unit1.GetType(), newUnit1.GetType()));
                }
            }
            foreach (Type t in Unit2.GetType().GetInterfaces())
            {
                if (newUnit2.GetType().GetInterface(t.Name) == null)
                {
                    throw new InvalidCastException(String.Format(CultureInfo.CurrentCulture, "You cannot convert {0} to {1}", Unit2.GetType(), newUnit2.GetType()));
                }
            }

            double firstUnitValue = ConvertUnits(newUnit1.GetType(), Unit1.GetType(), Value, Unit1Power);
            double newValue       = ConvertUnits(newUnit2.GetType(), Unit2.GetType(), firstUnitValue, Unit2Power);

            return(new Scalar <TN1, TN2>()
            {
                Value = newValue,
                Unit1 = newUnit1,
                Unit2 = newUnit2,
                Unit1Power = Unit1Power,
                Unit2Power = Unit2Power,
            });
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            // number
            StringBuilder returnString = new StringBuilder(Value.ToString(CultureInfo.CurrentCulture));

            // first unit
            returnString.AppendFormat(
                " {0}{1}",
                Unit1.GetType().Name,
                ((Unit1Power == 1) ?
                 String.Empty :
                 ("^" + Unit1Power)));

            // divider
            returnString.Append((Unit2Power < 0) ? "/" : "*");

            //second unit
            returnString.AppendFormat(
                "{0}{1}",
                Unit2.GetType().Name,
                ((Math.Abs(Unit2Power) == 1) ?
                 String.Empty :
                 ("^" + Math.Abs(Unit2Power))));

            return(returnString.ToString());
        }
Example #3
0
 //重置
 protected void DeleteAll_Click(object sender, EventArgs e)
 {
     try
     {
         //AwardPeople.Reset();
         //tAchievement.Reset();
         tachievement.Reset();
         tAwardName.Reset();
         dAwardTime.Reset();
         dAwardwSpecies.Reset();
         FirstAward.Reset();
         AwardNum.Reset();
         dAwardForm.Reset();
         dGrade.Reset();
         tRemark.Reset();
         dSecrecyLevel.Reset();
         tGivenAgency.Reset();
         Unit1.Reset();
         Unit2.Reset();
         Unit3.Reset();
         Unit4.Reset();
         Unit5.Reset();
         DropDownList_Sort.Reset();
         Members.Reset();
         PageContext.RegisterStartupScript("clearFile();");
     }
     catch (Exception ex)
     {
         pm.SaveError(ex, this.Request);
     }
 }
Example #4
0
 private void OnDestroy()
 {
     Unit0.Dispose();
     Unit0 = null;
     Unit1.Dispose();
     Unit1 = null;
     Steps = null;
 }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder returnString = new StringBuilder(Value.ToString(CultureInfo.CurrentCulture));

            if (Unit1Power == 1)
            {
                returnString.AppendFormat(" {0}", Unit1.GetType().Name);
            }
            else
            {
                returnString.AppendFormat(" {0}^{1}", Unit1.GetType().Name, Unit1Power);
            }

            return(returnString.ToString());
        }
Example #6
0
        static void Main(string[] args)
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.DarkBlue;
            Console.WriteLine("(_ ___)-._.-=-._.-=-._.-=-._.-=-._.-=-._.._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-(_ ___) \n");
            Console.WriteLine("                     .-\"\"\"\"-.        .-\"\"\"\"-. \n");
            Console.WriteLine("                    /        \\      /        \\ \n");
            Console.WriteLine("                   /_        _\\    /_        _\\ \n");
            Console.WriteLine("                  // \\      / \\   // \\      / \\ \n");
            Console.WriteLine("                  |\\__\\    /__/|  |\\__\\    /__/| \n");
            Console.WriteLine("                   \\    ||    /    \\    ||    /\\ \n");
            Console.WriteLine("                    \\        /      \\        /\n");
            Console.WriteLine("                     \\  __  /        \\  __  /  \n");
            Console.WriteLine("                      '.__.'          '.__.' \n");
            Console.WriteLine("                       |  |            |  |\n");
            Console.WriteLine("                       |  |            |  |\n");
            Console.WriteLine("                         👽 Ninjanauts 👽 \n");
            Console.WriteLine("\n");
            Console.WriteLine("(_ ___)-._.-=-._.-=-._.-=-._.-=-._.-=-._.._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-(_ ___) \n");
            Console.ResetColor();
            Console.WriteLine("Press any key to continue...\n");
            Console.ReadKey();

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("Planet Earth 🌍 year 2020... \n \n  Earth is corrupted with viruses and pollution, \n we have no choice left, but to send some brave people to space, \n their journey might not be successful, but they are our only hope... \n");
            Console.WriteLine("Press any key to continue...\n");
            Console.ReadKey();

            Console.Clear();
            Console.WriteLine("So far we have two candidates, let's see who is smarter, the will be the \"chose one\", he will be sent to space \n");
            Console.ResetColor();
            Console.WriteLine("Press any key to continue...\n");
            Console.ReadKey();

            Console.Clear();
            Library word  = new Library();
            Unit1   unit1 = new Unit1("ᕙ(▀̿̿Ĺ̯̿̿▀̿ ̿) ᕗ SAM the nerd");
            Unit2   unit2 = new Unit2("(‡▼益▼) geeky JACK");

            Console.BackgroundColor = ConsoleColor.Red;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("Let's the epic battle begin \n");
            Console.WriteLine($"{unit1.Name} vs. {unit2.Name} \n");
            Console.ResetColor();
            Console.WriteLine("Press any key to continue...\n");
            Console.ReadKey();

            //Console.Clear();
            while (!unit2.IsFull || !unit1.IsFull)
            {
                unit1.Consume(word.Serve());
                unit2.Consume(word.Serve());
            }

            Console.BackgroundColor = ConsoleColor.Red;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine($"{unit1.Name} learned {unit1.ConsumptionHistory.Count} books & {unit2.Name} learned {unit2.ConsumptionHistory.Count} books \n");

            Console.WriteLine("Press any key to continue...\n");
            Console.ReadKey();
            Console.Clear();

            if (unit1.ConsumptionHistory.Count > unit2.ConsumptionHistory.Count)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine("Mewnwhile in space...music plays\n");
                Console.WriteLine("Ground control to major tom ♪ ♪ ♪ \n  take your protein pills and put your helmet on...  ♫ ♫ ♫ \n our ninjanaut 🙭 is in space!...\n");
                Console.WriteLine($"The earth is saved...ninjanaut 🙭 {unit1.Name} is in space!");
                Console.ResetColor();
            }
            else if (unit2.ConsumptionHistory.Count > unit1.ConsumptionHistory.Count)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine("Mewnwhile in space...music plays\n");
                Console.WriteLine("Ground control to major tom ♪ ♪ ♪ \n  take your protein pills and put your helmet on...  ♫ ♫ ♫ \n our ninjanaut 🙭 is in space!...\n");
                Console.WriteLine($"The earth is saved...ninjanaut 🙭 {unit2.Name} is in space!");
                Console.ResetColor();
            }
            else
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine($"It looks to be like ☠ ninjanauts ☠ are both equal dumb \n the Earth is doomed, sorry for your loss ☠ ");
                Console.ResetColor();
                Console.ResetColor();
            }

            // Console.Clear();


            // Console.WriteLine("Press any key to continue...\n");
            // Console.ReadKey();
        }
Example #7
0
 public bool LoadCombatUnit(MapClass mapClass0, MapClass mapClass1)
 {
     return(Unit0.Load(mapClass0) && Unit1.Load(mapClass1));
 }