static void Main(string[] args) { math calc = Add; calc(14, 12); calc = Sub; calc(14, 12); Person p = new Person(); calc = p.AddtoCGPA; calc(90, 85); math cacl2 = Add; cacl2 += Sub; cacl2 += p.AddtoCGPA; cacl2(90, 85); cacl2 -= Sub; cacl2(90, 85); }
static void Main(string[] args) { math calc = Add; calc(8, 6); calc = Sub; calc(8, 6); Person p = new Person(); calc = p.AddtoCGPA; calc(80, 75); math cacl2 = Add; cacl2 += Sub; cacl2 += p.AddtoCGPA; cacl2(80, 75); cacl2 -= Sub; cacl2(80, 75); }
static void Main(string[] args) { Predicate <int> index1 = x => x == 4;//predicate with lamda expression math n2; math n1 = add; math n3 = multiply; n2 = n1; n2 += n3; int[] numbers = new int[] { 1, 2, 3, 4, 5, 6, 7 }; Array.ForEach(numbers, i => Console.WriteLine(i)); //lemda expression for for each loop in array List <int> list = new List <int> { 1, 2, 3, 4, 5 }; list.ForEach(i => Console.WriteLine(i)); int index = list.FindIndex(index1); Console.WriteLine(list[index]); Console.WriteLine(list[3]); //Console.WriteLine(n2(4)); math nc1 = num => num - 1; //lemda expression => is a lemda operator , in equation left side operator are arguments and right side is return value nc1(4); // Console.WriteLine(nc1(4)); }
static void Main(string[] args) { math yolo = new math(); Console.WriteLine(yolo.division(4, 2)); Console.WriteLine(yolo.division(8.8f, 2.2f)); Console.WriteLine(yolo.additive("2", "4")); }
public void FillDataX(math.Matrix X) { var r = Rounder; Text = this.Name + Environment.NewLine; for (int i = 0; i < X.LenghtX(); i++) { Text += Math.Round(X[i, 0], r).ToString().Replace(',', '.') + "\t"; Text += Math.Round(X[i, 1], r).ToString().Replace(',', '.') + Environment.NewLine; } }
public void FillData(math.Matrix X,math.Matrix Y) { verts.Clear(); var r = Rounder; Text = this.Name + Environment.NewLine; for (int i = 0; i < Y.LenghtX(); i++) { Text += Math.Round(Y[i, 0], r).ToString().Replace(',', '.') + Environment.NewLine; verts.Add(new double[] { X[i,0], Y[i, 0] }); } Verts = verts.OrderBy(x => x[0]).ToArray(); }
public CssBoxMathMLRoot CreateMathMLBox(CssBox parentBox, HtmlElement elementNode, LayoutFarm.Css.BoxSpec spec) { CssBoxMathMLRoot mathMLRoot = new CssBoxMathMLRoot(elementNode.Spec); MathMLDocument doc = new MathMLDocument(); doc.CssActiveSheet = new CssActiveSheet(); _currentDoc = doc; _docBuilder.ResultDoc = doc; _docBuilder.OnBegin(); math mathNode = new math(); _docBuilder.CurrentMathNode = mathNode; CreateBoxContent(elementNode); _docBuilder.OnEnd(); MathMLRootEventPortal mathMLController = new MathMLRootEventPortal(elementNode); mathMLRoot.SetController(mathMLController); parentBox.AppendChild(mathMLRoot); return(mathMLRoot); ////TODO: review here //// ////create blank svg document //VgDocument svgdoc = new VgDocument(); //svgdoc.CssActiveSheet = new LayoutFarm.WebDom.CssActiveSheet(); //_currentDoc = svgdoc; //_svgDocBuilder.ResultDocument = svgdoc; //// //_svgDocBuilder.OnBegin(); //CreateBoxContent(elementNode); //_svgDocBuilder.OnEnd(); ////----------------------------------------- //SvgRootEventPortal svgRootController = new SvgRootEventPortal(elementNode); //CssBoxSvgRoot svgRoot = new CssBoxSvgRoot( // elementNode.Spec, // svgdoc); //svgRoot.SetController(svgRootController); //svgRootController.SvgRoot = svgRoot; //parentBox.AppendChild(svgRoot); //return svgRoot; }
static void Main(string[] args) { ifly[] all = { new subomb("ahmed"), new plane(), new bird() }; foreach (ifly f in all) { Console.WriteLine(f); f.fly(); } math m = add; Console.WriteLine(x4(1, 1, m, sub)); Console.ReadLine(); }
protected void Button1_Click(object sender, EventArgs e) { try{ mathlib.math math = new math(); Int32 value1 = Convert.ToInt32(subValue1.Text.ToString()); Int32 value2 = Convert.ToInt32(subValue2.Text.ToString()); Int32 sub = math.Subtract(value1, value2); subValue.Text = "Subtract of two values are : " + sub.ToString(); subValue.ForeColor = System.Drawing.Color.White; } catch { subValue.Text = "Input Error"; subValue.ForeColor = System.Drawing.Color.Red; } }
protected void Button1_Click(object sender, EventArgs e) { try{ mathlib.math math = new math(); Int32 value1 = Convert.ToInt32(mulValue1.Text.ToString()); Int32 value2 = Convert.ToInt32(mulValue2.Text.ToString()); Int32 mul = math.Multiply(value1, value2); mulValue.Text = "Multiply of two values are : " + mul.ToString(); mulValue.ForeColor = System.Drawing.Color.White; } catch { mulValue.Text = "Input Error"; mulValue.ForeColor = System.Drawing.Color.Red; } }
public void Test1() { math M = new math(10, 10, 10); var result = M.triangleperim(); math N = new math(10, 10); var result1 = N.rectangleperim(); math P = new math(10); var result2 = P.squareperim(); Assert.IsType <int>(result); Assert.Equal(30, result); Assert.IsType <int>(result1); Assert.Equal(40, result1); Assert.IsType <int>(result2); Assert.Equal(40, result2); }
static double x4(double a, double b, math c, math d) { return(c(a, b) + d(a, b)); }
public void Multiplication() { mathlib.math math = new math(); Assert.AreEqual(100, math.Multiply(10, 10), "Multiplied values are equal and testing successful"); }
public void Subtraction() { mathlib.math math = new math(); Assert.AreEqual(5, math.Subtract(10, 5), "Subtraction values are equal and testing successful"); }
public void Addition() { mathlib.math math = new math(); Assert.AreEqual(20, math.Add(10, 10), "Additon values are equal and testing successful"); }
public static void Main(string[] args) { Console.WriteLine("MEH System Version 2.5"); Console.WriteLine("Loading Core System"); Console.WriteLine("Declaring Startup Variables"); //String dlls = "None"; String command, user, pass, secure = null; Boolean secure_mode = true; math math = new math(); Boolean shutDownFlag = true; Console.WriteLine("Startup Variables Declared"); Console.WriteLine("Searching for dlls"); int presentDefine = 1; if (presentDefine == -1) { Console.WriteLine("Define.dll not found, press a key to break"); Console.ReadKey(); return; } else { Console.WriteLine("All DLLs accounted for"); } Console.Write("Enter Secure Mode? "); secure = Console.ReadLine(); //string os = File.ReadAllText(@"os.txt"); string os = "linux"; switch (secure) { case "yes": secure_mode = true; break; case "y": secure_mode = true; break; case "true": secure_mode = true; break; case "no": secure_mode = false; break; case "n": secure_mode = false; break; case "false": secure_mode = false; break; default: Console.WriteLine("Invalid"); Console.ReadKey(); return; } if (secure_mode == true) { Console.WriteLine("Loading..."); Console.WriteLine("Enter User Name: "); user = Console.ReadLine(); Console.WriteLine("Enter Password: "******"admin") & string.Equals(pass, "admin")) { Console.WriteLine("Confirming credentials, please wait"); Console.WriteLine("Credentials confirmed, hello, " + user); } else { Console.WriteLine("Credentials Incorrect"); Console.ReadKey(); return; } } else if (secure_mode == false) { Console.WriteLine("Loading..."); Console.WriteLine("Enter User Name: "); user = Console.ReadLine(); Console.WriteLine("Confirming credentials, please wait"); Console.WriteLine("Credentials confirmed, hello, " + user); } while (true) { Console.WriteLine("How may I Help you?"); command = Console.ReadLine(); switch (command) { case "add": double ans = math.AddNumbers(); Console.WriteLine("Answer is " + ans); break; case "subtract": ans = math.SubNumbers(); Console.WriteLine("Answer is " + ans); break; case "multiply": ans = math.MulNumbers(); Console.WriteLine("Answer is " + ans); break; case "divide": ans = math.DivNumbers(); Console.WriteLine("Answer is " + ans); break; case "quit": return; case "define": if (os.Equals("windows")) { Console.Write("Define What? "); String define; define = Console.ReadLine(); var defineword = new Definition().WordDefine(define); Console.WriteLine(defineword); } else { Console.WriteLine("OS not supported"); } break; case "time": string time = DateTime.Now.ToString("h:mm:ss tt"); Console.WriteLine(time); break; case "what is the time": time = DateTime.Now.ToString("h:mm:ss tt"); Console.WriteLine(time); break; case "timer": int min, sec, totalsec, mintosec, milli; string strmin, strsec; Console.Write("Minutes: "); strmin = Console.ReadLine(); Console.Write("Seconds: "); strsec = Console.ReadLine(); sec = Int32.Parse(strsec); min = Int32.Parse(strmin); mintosec = min * 60; totalsec = mintosec + sec; milli = totalsec * 1000; System.Threading.Thread.Sleep(milli); Console.WriteLine("Time is Up"); break; case "bench": Console.WriteLine("Initializing benchmarking subroutine"); System.Threading.Thread.Sleep(1000); Console.WriteLine("Running benchmark test 1"); System.Threading.Thread.Sleep(10000); Console.WriteLine("done"); System.Threading.Thread.Sleep(5000); Console.WriteLine("Running benchmark test 2"); System.Threading.Thread.Sleep(10000); Console.WriteLine("done"); System.Threading.Thread.Sleep(5000); Console.WriteLine("Calculating"); System.Threading.Thread.Sleep(10000); Console.WriteLine("Just kidding, master did not teach me to benchmark."); System.Threading.Thread.Sleep(5000); Console.WriteLine("But I feel bad so here is the link to novabench: https://novabench.com"); Console.WriteLine("they can run a benchmark for you. :-)"); break; case "exit": return; case "NRK": Console.WriteLine("too bad NRK is not so easy to access"); Console.WriteLine("please enter the NRK username to gain access"); user = Console.ReadLine(); Console.WriteLine("please enter the super secret password which only a NRK member would know"); pass = Console.ReadLine(); if (string.Equals(user, "NRK") & string.Equals(pass, "Supreme")) { Console.WriteLine("Confirming credentials, please wait"); Console.WriteLine("Credentials confirmed, hello, " + user); } else { Console.WriteLine("go back you fake wannabe NRK"); Console.ReadKey(); return; } break; case "nuke it": return; default: Console.WriteLine("What?I do not follow....."); break; case "how are you": Console.WriteLine("my sole purpose of existing " + "is to fullfil your needs, how am I is not the question, its all about you"); break; case "what is your name": Console.WriteLine("I am an AI you can call me ****"); System.Threading.Thread.Sleep(1000); Console.WriteLine("A message from the developers:"); System.Threading.Thread.Sleep(1000); Console.WriteLine("Sorry about that"); System.Threading.Thread.Sleep(1000); Console.WriteLine("It's just a phase"); System.Threading.Thread.Sleep(1000); Console.WriteLine("We think"); System.Threading.Thread.Sleep(1000); Console.WriteLine("And hope"); System.Threading.Thread.Sleep(1000); break; case "shut down": Console.WriteLine("LOL...no one can shut me down"); if (shutDownFlag == true) { Console.WriteLine("please enter the code to gain access to my mainframe"); user = Console.ReadLine(); Console.WriteLine("nothing can stop exept the last code!!!!!"); Console.WriteLine("message from the dev team"); System.Threading.Thread.Sleep(1000); Console.WriteLine("it is the most easy four character password....1..2.."); pass = Console.ReadLine(); if (string.Equals(user, "0987") & string.Equals(pass, "1234")) { Console.WriteLine("noooo..."); return; //This line makes it exit } else { Console.WriteLine("i cannot be stopped"); shutDownFlag = false; } } break; case "area": Console.WriteLine("Area"); Console.WriteLine("of square = Side * Side"); Console.WriteLine("of rectangle = Length * Breath"); Console.WriteLine("of triangle = Base * Perpendicular height / 2"); Console.WriteLine("of trapezium = (side a + side b) * height / 2"); Console.WriteLine("of parallelogram = Base * Perpendicular Height"); Console.WriteLine("of kite = (Diagonal p) * (Diagonal q) / 2"); Console.WriteLine("51 = Who Knows"); break; case "open chrome": string page = "https://www.google.com"; Console.Write("Which Page (Use format like https://google.com): "); page = Console.ReadLine(); Process.Start("chrome", @page); break; case "open microsoft edge": Process.Start("microsoft-edge:http://www.google.com"); break; case "open NRK entertainment website": Process.Start("http://nrk-entertainment.webnode.com/ "); break; case "battery": var BatteryChargeStatus = SystemInformation.PowerStatus.BatteryChargeStatus.ToString(); var BatteryFullLifetime = SystemInformation.PowerStatus.BatteryFullLifetime.ToString(); var BatteryLifePercent = SystemInformation.PowerStatus.BatteryLifePercent.ToString(); var BatteryLifeRemaining = SystemInformation.PowerStatus.BatteryLifeRemaining.ToString(); var PowerLineStatus = SystemInformation.PowerStatus.PowerLineStatus.ToString(); Console.WriteLine("Percent is " + BatteryLifePercent); Console.WriteLine("Charge status is " + BatteryChargeStatus); Console.WriteLine("Full lifetime is " + BatteryFullLifetime); Console.WriteLine("Remaining lifetime is " + BatteryLifeRemaining); Console.WriteLine("Powerline status is " + PowerLineStatus); break; case "weather": var result = CurrentWeather.GetByCityName("Stockholm", "Sweden", "en", "metric"); Console.WriteLine(result); break; case "periodic table": Process.Start("https://www.ptable.com/"); break; case "serial": seRead.Begin.Start(); break; } } }
//Create a new param object for adding params public static Parameter getParam(Int16 hsh, string nme, Int32 vlen, int val, Parameter prm, Color clor, math.vector v, valueType f) { prm.hash = hsh; prm.nb = 0; prm.name = nme; prm.flag = f; prm.valueLength = vlen; switch(vlen){ case 2: prm.intValue = (Int16)val; break; case 4: if (f == valueType.integer){ prm.intValue = val; } if (f == valueType.dub) { prm.dubValue = val; } if (f == valueType.color) { prm.colorVal = clor; } break; case 12: f = valueType.vec; prm.vec = v; break; } return prm; }
static void Main(string[] args) { math math = new math(); Console.WriteLine(math.Power(2, 3)); }