本文整理汇总了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";
}
}
示例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);
}
示例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);
}
示例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;
}
示例5: Segment
public Segment (Point sp, Point ep, Fraction segmentSlope)
{
StartPoint = sp;
EndPoint = ep;
Slope = segmentSlope;
}
示例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);
}
示例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);
}
}
示例8: NextChallenge
public void NextChallenge(Fraction[] fractions, Fraction fraction)
{
tryBtn.enabled = false;
Views.TogglesEnabled(pizzas, true);
SetFraction(fraction);
SetPizzas(fractions);
}
示例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));
}
示例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);
}
示例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);
}
示例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;
}
示例13: PizzaResourceToImages
public static void PizzaResourceToImages(Fraction fraction, Image[] images)
{
foreach (Image image in images)
{
PizzaResourceToImage(fraction, image);
}
}
示例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);
}
示例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;
}