Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter class id to start:");
            Console.WriteLine("Point Class:1");
            Console.WriteLine("Counter Class:2");
            Console.WriteLine("Car Class:3");
            Console.WriteLine("Fraction Calculator Class:4");
            Console.Write("Your Choice:");
            int option = Convert.ToInt32(Console.ReadLine());

            if (option == 1)
            {
                Console.WriteLine("Point Class:");
                Point point = new Point(17, 17);
                point.showData();
            }
            if (option == 2)
            {
                Console.WriteLine("\nCount Class:");
                Counter counter = new Counter(1, 17);
                for (int i = 0; i < 17; i++)
                {
                    counter.increase();
                    Console.Write(counter.currentValue + " ");
                }
                Console.WriteLine("\n");
            }
            if (option == 3)
            {
                Car jeep       = new Car(1, 5.7, "Jeep", "Grand Cheeroke", 2014);
                Car mazda      = new Car(2, 2.7, "Mazda", "CX-5", 2018);
                Car mitsubishi = new Car(3, 3.0, "Mitsubishi", "Evolution MR8", 2008);
                jeep.showCarData();
                mazda.showCarData();
                mitsubishi.showCarData();
            }
            if (option == 4)
            {
                Console.WriteLine("Fraction Calculator Class:");
                Console.Write("Enter the first number:");
                double value1 = Convert.ToDouble(Console.ReadLine());
                Console.Write("Enter the operator:");
                string symbol = Console.ReadLine();
                Console.Write("Enter the second number:");
                double             value2        = Convert.ToDouble(Console.ReadLine());
                FractionCalculator f1            = new FractionCalculator(value1);
                FractionCalculator f2            = new FractionCalculator(value2);
                FractionCalculator forOperations = new FractionCalculator();
                if (symbol == "+")
                {
                    Console.WriteLine(forOperations.Addition(f1, f2));
                }
                if (symbol == "-")
                {
                    Console.WriteLine(forOperations.Subtraction(f1, f2));
                }
                if (symbol == "*")
                {
                    Console.WriteLine(forOperations.Multiplication(f1, f2));
                }
                if (symbol == "/")
                {
                    Console.WriteLine(forOperations.Division(f1, f2));
                }
            }
            ForHoldProgram();
        }
Ejemplo n.º 2
0
 public double Division(FractionCalculator fraction1, FractionCalculator fraction2)
 {
     return(fraction1.Value / fraction2.Value);
 }
Ejemplo n.º 3
0
 public double Subtraction(FractionCalculator fraction1, FractionCalculator fraction2)
 {
     return(fraction1.Value - fraction2.Value);
 }
Ejemplo n.º 4
0
 public double Multiplication(FractionCalculator fraction1, FractionCalculator fraction2)
 {
     return(fraction1.Value * fraction2.Value);
 }
Ejemplo n.º 5
0
 public double  Addition(FractionCalculator fraction1, FractionCalculator fraction2)
 {
     return(fraction1.Value + fraction2.Value);
 }