To be clear, having trouble with a homework problem. Don't want solution, just clarify some points. Problem and code follows.

I can't wrap my head around how to create the variables for the class methods, incorporate into method return, and then pass the values in the instances to the method call in the program. i.e. Fractions.add(). I can of course figure out the rest of the methods if I could understand the first one. Any clarification would help.

Functionality

Define a class called Fraction that houses a long numerator and long denominator. The constructor

should accept two parameters representing the numerator and denominator respectively. If the caller

passes a denominator of 0, display an error message using Console.WriteLine, wait for the user to hit

ENTER, and exit the program using Environment.Exit.

Your Fraction class needs to implement the following methods:

Add. Calculates the sum of two fractions and returns the result as a Fraction.

Subtract. Calculates the difference of two fractions and returns the result as a Fraction. \

Multiply. Calculates the product of two fractions and returns the result as a Fraction.

DivideBy. Calculates the quotient of the two fractions and returns the result as a Fraction.

Reduced. Calculates the reduced version of the fraction, e.g., 5 / 10 reduced is 1 / 2 and 6 / 20

reduced is 3 / 10.

Here is what I have so far.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

public class Fractions

{

public long Num { get; set; }

public long Denom { get; set; }

public Fractions(long num, long denom)

{

Num = num;

Denom = denom;

}

public long add()

{

return );

}

}

}

class Program

{

static void Main()

{

Fractions fraction1 = new Fractions(5, 12);

Console.WriteLine("fraction1 Num = {0} Denom = {1}", fraction1.Num, fraction1.Denom);

Fractions fraction2 = new Fractions(6, 12);

Console.WriteLine("fraction2 Num = {0} Denom = {1}", fraction2.Num, fraction2.Denom);

if (fraction1.Denom == 0 || fraction2.Denom == 0)

{

Console.WriteLine(" Error. Denominator Cannot Be 0. Please Press Enter to Exit Program.");

Console.ReadKey();

Environment.Exit(1);

}

else

{

Console.WriteLine("fraction1 Num = {0} Denom = {1}", fraction1.Num, fraction1.Denom);

Console.WriteLine("fraction2 Num = {0} Denom = {1}", fraction2.Num, fraction2.Denom);

Fractions.add();

// Keep the console open in debug mode.

Console.WriteLine("Press any key to exit.");

Console.ReadKey();

}

}

}

}

I apologize about the formatting of the code. I read the homework FAQs but didn't quite understand the procedure for retaining formatting.