当前位置: 首页>>代码示例>>C#>>正文


C# Fraction类代码示例

本文整理汇总了C#中Fraction的典型用法代码示例。如果您正苦于以下问题:C# Fraction类的具体用法?C# Fraction怎么用?C# Fraction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Fraction类属于命名空间,在下文中一共展示了Fraction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Card

        public Card(int i, Fraction f)
        {

            int n;
            if (f == Fraction.Dragon)
            {
                n = Card.dragonCards;
                action1 = dragonActionsDictionary[i][0];
                if (dragonActionsDictionary[i].Count > 1)
                    action2 = dragonActionsDictionary[i][1];
                else action2 = action1;
            }
            else
            {
                n = Card.dwarfCards;
                action1 = dwarfsActionsDictionary[i][0];
                if (dwarfsActionsDictionary[i].Count > 1)
                    action2 = dwarfsActionsDictionary[i][1];
                else action2 = action1;
            }
                
                
            if (i > 0 && i <= n)
            {
                id = i;
                fraction = f;
                string c;                
                if (fraction == Fraction.Dwarf)               
                    c = "K";               
                    else
                    c = "D";
                src = "Images/Cards/" + c + id.ToString()+".png";
            }
        }      
开发者ID:Zimex,项目名称:Tess,代码行数:34,代码来源:Card.cs

示例2: Solve

        public long Solve()
        {
            var indexes = new int[Limit];

            var value = 2;

            for (var i = 0; i < Limit; i++)
            {
                if (((i - 1) % 3) != 0)
                {
                    indexes[i] = 1;
                }
                else
                {
                    indexes[i] = value;
                    value = 2 + value;
                }
            }

            var fractal = new Fraction(1, indexes[Limit - 1]); // 1/ cislo
            for (var i = Limit - 2; i >= 0; i--)
            {
                fractal.Update(indexes[i]);

                Console.WriteLine("{0} / {1}", fractal.TopPart, fractal.DownPart);
            }

            var result = fractal.TopPart + (fractal.DownPart * 2);

            Console.WriteLine("{0} / {1}", fractal.TopPart + (fractal.DownPart * 2), fractal.DownPart);

            return (long)SumOfDigits(result);
        }
开发者ID:joeazbest,项目名称:Euler,代码行数:33,代码来源:Problem065.cs

示例3: SubtractFraction

        public decimal SubtractFraction(Fraction firstFraction, Fraction secondFraction)
        {
            newFraction.Numerator = firstFraction.Numerator * secondFraction.Denominator - secondFraction.Numerator * firstFraction.Denominator;
            newFraction.Denominator = firstFraction.Denominator * secondFraction.Denominator;

            return Math.Round(Decimal.Divide(newFraction.Numerator,newFraction.Denominator), 2, MidpointRounding.AwayFromZero);
        }
开发者ID:xxli807,项目名称:IdeaPractices,代码行数:7,代码来源:OperationService.cs

示例4: Create

 static void Create(Fraction f)
 {
     FractionInfo i = new FractionInfo();
     switch (f) {
         case Fraction.Humans:
             i.name="Human Alliance";
             i.emblem = "/Humans/Emblem.gif";
             i.smallEmblem = "/Humans/SmallEmblem.gif";
             break;
         case Fraction.Orcs:
             i.name = "Horde";
             i.emblem = "/Orcs/Emblem.gif";
             i.smallEmblem = "/Orcs/SmallEmblem.gif";
             break;
         case Fraction.NightElves:
             i.name = "Night Elves";
             i.emblem = "/NightElves/Emblem.gif";
             i.smallEmblem = "/NightElves/SmallEmblem.gif";
             break;
         case Fraction.Undead:
             i.name = "Undead Scourge";
             i.emblem = "/Undead/Emblem.gif";
             i.smallEmblem = "/Undead/SmallEmblem.gif";
             break;
         case Fraction.Neutrals:
             i.name = "Creeps";
             i.emblem = "";
             i.smallEmblem = "";
             break;
     }
     infos[f] = i;
 }
开发者ID:BackupTheBerlios,项目名称:wc3o-svn,代码行数:32,代码来源:FractionInfo.cs

示例5: Segment

 public Segment (Point sp, Point ep, Fraction segmentSlope)
 {
   StartPoint = sp;
   EndPoint = ep;
   
   Slope = segmentSlope;
 }
开发者ID:jansky,项目名称:JanskyMath,代码行数:7,代码来源:Geometry.cs

示例6: Main

    static void Main()
    {
        Console.WriteLine("Enter fraction");
        string input = Console.ReadLine();
        Fraction fraction = new Fraction();
        fraction = fraction.Parce(input);
        fraction.CalculateFractionValue();
        Console.WriteLine("Decimal value of the fraction is:");
        Console.WriteLine(fraction.FractionValue);
        fraction.Cut();
        Console.WriteLine("Fraction after cut is:");
        Console.WriteLine(fraction.ToString());
        Console.WriteLine("Decimal value of the cut fraction is:");
        Console.WriteLine(fraction.FractionValue);

        Console.WriteLine("Enter numerator");
        int numerator = int.Parse(Console.ReadLine());
        Console.WriteLine("Enter denumerator");
        int denumerator = int.Parse(Console.ReadLine());
        Fraction otherFraction = new Fraction(numerator, denumerator);
        Console.WriteLine("Fraction is:");
        Console.WriteLine(otherFraction.ToString());
        otherFraction.CalculateFractionValue();
        Console.WriteLine("Decimal value of the fraction is:");
        Console.WriteLine(otherFraction.FractionValue);
        otherFraction.Cut();
        Console.WriteLine("Fraction after cut is:");
        Console.WriteLine(otherFraction.ToString());
        Console.WriteLine("Decimal value of the cut fraction is:");
        Console.WriteLine(otherFraction.FractionValue);
    }
开发者ID:vasilkrvasilev,项目名称:ObjectOrientedProgramming,代码行数:31,代码来源:FractionTest.cs

示例7: Main

    static void Main()
    {
        try
        {
            Fraction fraction1 = new Fraction();
            Fraction fraction2 = new Fraction();

            Console.WriteLine("Please enter fraction1 numerator: ");
            fraction1.Numerator = int.Parse(Console.ReadLine());
            Console.WriteLine("Please enter fraction2 numerator: ");
            fraction1.Denominator = int.Parse(Console.ReadLine());
            Console.WriteLine("Please enter fraction1 denominator: ");
            fraction2.Numerator = int.Parse(Console.ReadLine());
            Console.WriteLine("Please enter fraction2 denominator: ");
            fraction2.Denominator = int.Parse(Console.ReadLine());

            Fraction additionResult = fraction1 + fraction2;
            Fraction substractionResult = fraction1 - fraction2;

            Console.WriteLine(additionResult.Numerator);
            Console.WriteLine(additionResult.Denominator);
            Console.WriteLine(additionResult);
            Console.WriteLine(substractionResult);
        }
        catch (ArgumentException aex)
        {
            Console.WriteLine(aex.Message);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Invalid number! " + ex.Message);
        }
    }
开发者ID:bnaskov,项目名称:SoftUni,代码行数:33,代码来源:Demo.cs

示例8: NextChallenge

 public void NextChallenge(Fraction[] fractions, Fraction fraction)
 {
     tryBtn.enabled = false;
     Views.TogglesEnabled(pizzas, true);
     SetFraction(fraction);
     SetPizzas(fractions);
 }
开发者ID:NashIlli,项目名称:calculandox,代码行数:7,代码来源:CookingPizzasView.cs

示例9: Main

 static void Main()
 {
     Fraction a = new Fraction(1, 2);
         Fraction b = new Fraction(3, 7);
         Fraction c = new Fraction(2, 3);
         Console.WriteLine((double)(a * b + c));
 }
开发者ID:terryjintry,项目名称:OLSource1,代码行数:7,代码来源:operator--csharp-reference-2_1.cs

示例10: Main

 static void Main()
 {
     Fraction temp = new Fraction(1, 1);
     temp = temp + new Fraction(5, 2);
     temp = temp - new Fraction(8, 2);
     Console.WriteLine(temp);
 }
开发者ID:shnogeorgiev,项目名称:Software-University-Courses,代码行数:7,代码来源:FractionCalculatorDemo.cs

示例11: RemoveDigit

 public void RemoveDigit()
 {
     Fraction f = new Fraction(13, 43);
     Fraction newf = f.RemoveDigit('3');
     Assert.AreEqual(1, newf.Nominator);
     Assert.AreEqual(4, newf.Denominator);
 }
开发者ID:johannsutherland,项目名称:ProjectEuler,代码行数:7,代码来源:UnitTest1.cs

示例12: GameMultiplayerControl

        public GameMultiplayerControl(Control Control, GameScreen GameScreen, int MapIndex, int SaveGameIndex, MultiplayerMatchStartInformation MP)
            : base(Control, GameScreen, MapIndex, SaveGameIndex, true)
        {
            this.UserName = MP.UserName;
            this.Password = MP.Password;
            this.MatchId = MP.MatchId;
            this.GameState = 0;
            this.MultiplayerMatch = true;
            this.MultiplayerFraction = MP.MultiplayerFraction;

            // timer checking if a newer game state is available
            NewGameStateAvailableTimer = new System.Windows.Forms.Timer();
            NewGameStateAvailableTimer.Interval = 1000;
            NewGameStateAvailableTimer.Tick += UpdateGameState;
            NewGameStateAvailableTimer.Start();

            // show multiplayer tab (gui) and update it's content
            GameScreen.TabItem_Multiplayer.Visibility = Visibility.Visible;
            GameScreen.Button_Restart.IsEnabled = false; // disable restart map button for multiplayer matches
            GameScreen.Label_Multiplayer_MatchID.Content = R.String("MatchID") + ": " + MatchId.ToString();
            GameScreen.Label_Multiplayer_MatchVersion.Content = R.String("MatchVersion") + ": " + GameState.ToString();

            // background worker
            BackgroundWorkerDownloadLatestGameState.DoWork += BackgroundWorkerDownloadLatestGameStateWork;
            BackgroundWorkerDownloadLatestGameState.RunWorkerCompleted += BackgroundWorkerDownloadLatestGameState_RunWorkerCompleted;
        }
开发者ID:Simsso,项目名称:Crusades,代码行数:26,代码来源:GameMultiplayerControl.cs

示例13: PizzaResourceToImages

 public static void PizzaResourceToImages(Fraction fraction, Image[] images)
 {
     foreach (Image image in images)
     {
         PizzaResourceToImage(fraction, image);
     }
 }
开发者ID:NashIlli,项目名称:calculandox,代码行数:7,代码来源:Fractions.cs

示例14: ComplexFractionConstructor

        public void ComplexFractionConstructor()
        {
            var complex1 = new Fraction(new Fraction(3, 2), new Fraction(2, 5));
            var complex2 = new Fraction(3, 2)/new Fraction(2, 5);

            Assert.IsTrue(complex1 == complex2);
        }
开发者ID:furesoft,项目名称:Mathos-Project,代码行数:7,代码来源:FractionTest.cs

示例15: GetAnsweredArray

 int[] GetAnsweredArray(Fraction[] ordered)
 {
     int[] result = new int[ordered.Length];
     for(int i = 0; i < ordered.Length; i++) {
         result[i] = Array.IndexOf(ordered, allFractions[i]) + 1;
     }
     return result;
 }
开发者ID:NashIlli,项目名称:calculandox,代码行数:8,代码来源:FractionsInOrderModel.cs


注:本文中的Fraction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。