public void menu_driven() { mathematics obj = new mathematics(); int option; while (true) { try{ option = obj.show_options(); }catch (Exception) { Console.WriteLine("Incorrect input"); continue; } switch (option) { case 0: Console.WriteLine("Error found in program"); System.Environment.Exit(0); break; case 1: obj.find_factorial(); break; case 2: obj.is_number_prime(); break; case 3: System.Environment.Exit(0); break; default: Console.WriteLine("Wrong Choice..!!"); break; } } }
static void Main(string[] args) { mathematics ac = new mathematics(); int a = 10; int b = 20; Console.WriteLine(ac.addition(a, b)); Console.ReadKey(); }
public void find_factorial() { mathematics obj = new mathematics(); try{ int number = obj.read_number(); Console.WriteLine("Factorial of {0} = {1}", number, obj.factorial(number)); }catch (Exception e) { Console.WriteLine("mathematics.find_factorial :- {0}", e); }finally{ Console.ReadKey(); } }
public int show_options() { mathematics obj = new mathematics(); try{ Console.WriteLine("Menu"); Console.WriteLine("1- Factorial"); Console.WriteLine("2- Check Prime"); Console.WriteLine("3- Exit"); Console.Write("Option : "); int option = int.Parse(Console.ReadLine()); return(option); }catch (Exception e) { Console.WriteLine("mathematics.show_options :- {0}", e); return(0); } }
public void is_number_prime() { mathematics obj = new mathematics(); try{ int number = obj.read_number(); if (obj.is_prime(number)) { Console.WriteLine("{0} is a Prime number", number); } else { Console.WriteLine("{0} is not a Prime number", number); } }catch (Exception e) { Console.WriteLine("mathematics.is_number_prime :- {0}", e); }finally{ Console.ReadKey(); } }
/// <summary> /// This function tranform the current canvas coordonate to physic engine coordonate /// </summary> /// <param name="vector">the 3D vector to set</param> /// <param name="canvasCoordonate">the point in canvas coordonate</param> public void SetVectorFromCanvasCoodonate(mathematics.Vector3D vector, Point canvasCoordonate) { vector.X = Convert.ToSingle(((canvasCoordonate.X - (this.graphCanvas.ActualWidth / 2d)) / this.CurrentZoomRatio) + this.center.X); vector.Y = Convert.ToSingle(((canvasCoordonate.Y - (this.graphCanvas.ActualHeight / 2d)) / this.CurrentZoomRatio) + this.center.Y); }
/// <summary> /// This function transform physic engine coordonate in the current canvas coordonate /// </summary> /// <param name="vector">the physics engine coodonate</param> /// <returns>the equivalent coordonate in the canvas</returns> public Point GetCanvasCoordonate(mathematics.Vector3D vector) { Point point = new Point(); point.X = ((vector.X - this.center.X) * this.CurrentZoomRatio) + (this.graphCanvas.ActualWidth / 2d); point.Y = ((vector.Y - this.center.Y) * this.CurrentZoomRatio) + (this.graphCanvas.ActualHeight / 2d); return point; }