public void PlusMinusTests() { // Case One (Correct) var inputCaseOne = new int[6] { -4, 3, -9, 0, 4, 1 }; var exerciseCaseOne = new PlusMinus(inputCaseOne); var expectedOutputCaseOne = new double[3] { 0.5, 0.333333, 0.166667 }; var resultCaseOne = exerciseCaseOne.Execute(); CollectionAssert.AreEqual(expectedOutputCaseOne, resultCaseOne); // Case Two (Check Constraints) var inputCaseTwo = new int[6] { -4000, 3, -9, 0, 4, 1 }; Assert.ThrowsException <ConstraintException>( () => new PlusMinus(inputCaseTwo)); }
public string TotalsToString(string formatString) { var min = MinutesPlayed.ToString(CultureInfo.InvariantCulture); var fg = FGM.ToString(CultureInfo.InvariantCulture) + "-" + FGA.ToString(CultureInfo.InvariantCulture); var threeP = ThreePM.ToString(CultureInfo.InvariantCulture) + "-" + ThreePA.ToString(CultureInfo.InvariantCulture); var ft = FTM.ToString(CultureInfo.InvariantCulture) + "-" + FTA.ToString(CultureInfo.InvariantCulture); var pts = Points.ToString(CultureInfo.InvariantCulture); var oreb = OffRebounds.ToString(CultureInfo.InvariantCulture); var dreb = DefRebounds.ToString(CultureInfo.InvariantCulture); var reb = Rebounds.ToString(CultureInfo.InvariantCulture); var ast = Assists.ToString(CultureInfo.InvariantCulture); var stl = Steals.ToString(CultureInfo.InvariantCulture); var blk = Blocks.ToString(CultureInfo.InvariantCulture); var to = Turnovers.ToString(CultureInfo.InvariantCulture); var pf = Fouls.ToString(CultureInfo.InvariantCulture); var pm = PlusMinus.ToString(CultureInfo.InvariantCulture); var pip = PointsInPaint.ToString(CultureInfo.InvariantCulture); var secChP = SecondChancePoints.ToString(CultureInfo.InvariantCulture); var fbPts = FastBreakPoints.ToString(CultureInfo.InvariantCulture); var ptsTO = PointsOffTurnovers.ToString(CultureInfo.InvariantCulture); var dunks = Dunks.ToString(CultureInfo.InvariantCulture); var app = Appearances.ToString(CultureInfo.InvariantCulture); string stats = string.Format(formatString, Desc, min, fg, threeP, ft, pts, oreb, dreb, reb, ast, stl, blk, to, pf, pm, pts, pip, secChP, fbPts, ptsTO, dunks, app); return(stats); }
public void PlusMinusTest() { var expected = new decimal[] { 0.500000M, 0.333333M, 0.166667M }; var result = PlusMinus.Run(6, new int[] { -4, 3, -9, 0, 4, 1 }); Assert.AreEqual(expected, result); }
public void plusMinusTest() { int[] array1 = { -4, 3, -9, 0, 4, 1 }; double[] expected = { 0.500000, 0.333333, 0.166667 }; double[] result = PlusMinus.plusMinus(array1); CollectionAssert.AreEqual(expected, result); }
static void Main(string[] args) { //================================================================// //================================================================// //WarmUP MODULE // //================================================================// //================================================================// #region [===== WarmUP MODULE =====] //Console.WriteLine("================ TEST 01 ==============="); //var test01 = new SolveMeFirst(); //test01.Start(); Console.WriteLine("================ TEST 02 ==============="); var test02 = new SimpleArraySum(); test02.Start(); Console.WriteLine("================ TEST 03 ==============="); var test03 = new CompareTheTriplets(); test03.Start(); Console.WriteLine("================ TEST 04 ==============="); var test04 = new AVeryBigSum(); test04.Start(); Console.WriteLine("================ TEST 05 ==============="); var test05 = new DiagonalDifference(); test05.Start(); Console.WriteLine("================ TEST 06 ==============="); var test06 = new PlusMinus(); test06.Start(); Console.WriteLine("================ TEST 07 ==============="); var test07 = new MiniMaxSum(); test07.Start(); Console.WriteLine("================ TEST 08 ==============="); var test08 = new Staircase(); test08.Start(); Console.WriteLine("================ TEST 09 ==============="); var test09 = new BirthdayCakeCandles(); test09.Start(); Console.WriteLine("================ TEST 10 ==============="); var test10 = new TimeConversion(); test10.Start(); Console.WriteLine("================ TEST 11 ==============="); #endregion }
public void PlusMinusPrint() { var array = new int[] { -4, 3, -9, 0, 4, 1 }; var result = PlusMinus.PrintPlusMinus(array); Assert.AreEqual(0.500000, result[0]); Assert.AreEqual(0.333333, result[1]); Assert.AreEqual(0.166667, result[2]); }
public void plusMinusTest() { //Arrange string[] expected = { "0.333333", "0.333333", "0.333333" }; int[] toPass = { 1, -1, 0 }; var actual = PlusMinus.plusMinus(toPass); //Assert CollectionAssert.AreEqual(expected, actual, $"Incorrect calues inside of array"); }
/// <summary> /// 撮影終了地点に到着してるかどうかを判定します. /// </summary> /// <param name="direction">移動方向</param> /// <returns>true:到着してる, false:到着していない</returns> private bool isOnEndPoint(PlusMinus direction) { bool flag = false; MotorControler mc = MotorControler.GetInstance(parameterManager); double point = mc.GetPoint().Z; switch (direction) { case PlusMinus.Plus: flag = (startPoint <= endPoint); break; case PlusMinus.Minus: flag = (startPoint >= endPoint); break; } return(flag); }
/// <summary> /// Create a button used to increment/decrement hours or minutes /// </summary> private UIButton CreatePlusMinusButton(PlusMinus plusMinus, EventHandler handler) { var button = CreateButton(); button.TouchUpInside += handler; switch (plusMinus) { case PlusMinus.Minus: button.SetTitle("-", UIControlState.Normal); button.TitleLabel.TextAlignment = UITextAlignment.Right; break; default: button.SetTitle("+", UIControlState.Normal); button.TitleLabel.TextAlignment = UITextAlignment.Left; break; } return(button); }
// 実設定 /// <summary> /// ブラーを変えるよ /// </summary> /// <param name="ps">加算か減算か</param> public void BlurChange(PlusMinus ps) { int Math = (ps == PlusMinus.plus) ? 1 : -1; // ブラーの段階を変えます BlurCount += 1 * Math; if (BlurFloor > BlurCount || BlurCount > BlurCeling) { if (BlurFloor > BlurCount - 1) { BlurCount += 1; } if (BlurCeling < BlurCount + 1) { BlurCount -= 1; } } BlurOptim.downsample = BlurCount; BlurOptim.blurIterations = BlurCount + 1; }
public string ToString(string formatString, string gameTime) { //Concatenate the in game prefix (should show *SG* if in at SG) prior to the name var name = FullName; if (gameTime != "FINAL") { name = InGame + name; } var min = MinutesPlayed.ToString(CultureInfo.InvariantCulture); var fg = FGM.ToString(CultureInfo.InvariantCulture) + "-" + FGA.ToString(CultureInfo.InvariantCulture); var threeP = ThreePM.ToString(CultureInfo.InvariantCulture) + "-" + ThreePA.ToString(CultureInfo.InvariantCulture); var ft = FTM.ToString(CultureInfo.InvariantCulture) + "-" + FTA.ToString(CultureInfo.InvariantCulture); var pts = Points.ToString(CultureInfo.InvariantCulture); var oreb = OffRebounds.ToString(CultureInfo.InvariantCulture); var dreb = DefRebounds.ToString(CultureInfo.InvariantCulture); var reb = Rebounds.ToString(CultureInfo.InvariantCulture); var ast = Assists.ToString(CultureInfo.InvariantCulture); var stl = Steals.ToString(CultureInfo.InvariantCulture); var blk = Blocks.ToString(CultureInfo.InvariantCulture); var to = Turnovers.ToString(CultureInfo.InvariantCulture); var pf = Fouls.ToString(CultureInfo.InvariantCulture); var pm = PlusMinus.ToString(CultureInfo.InvariantCulture); var prf = PointsResponsibleFor.ToString(CultureInfo.InvariantCulture); var pip = PointsInPaint.ToString(CultureInfo.InvariantCulture); var secChP = SecondChancePoints.ToString(CultureInfo.InvariantCulture); var fbPts = FastBreakPoints.ToString(CultureInfo.InvariantCulture); var ptsTO = PointsOffTurnovers.ToString(CultureInfo.InvariantCulture); var dunks = Dunks.ToString(CultureInfo.InvariantCulture); var touches = Touches.ToString(CultureInfo.InvariantCulture); var touchTime = Math.Round(TouchTime, 0, MidpointRounding.AwayFromZero).ToString(CultureInfo.InvariantCulture); var stats = string.Format(formatString, name, min, fg, threeP, ft, pts, oreb, dreb, reb, ast, stl, blk, to, pf, pm, prf, pip, secChP, fbPts, ptsTO, dunks, touches, touchTime); return(stats); }
private void OnTriggerStay(Collider other) { switch (other.tag) { case "DIGITAL": Manager.Connect1 = 1; socket = other.gameObject; Manager.DigitalConnect = true; Manager.parent = other.gameObject; Manager.Power = 1; break; case "GND": Manager.Connect1 = 1; socket = other.gameObject; Manager.GNDConnect = true; Manager.parent = other.gameObject; break; case "VCC": Manager.Connect1 = 1; socket = other.gameObject; Manager.VccConnect = true; Manager.parent = other.gameObject; if (other.name == "5V") { Manager.Power = 5; } else if (other.name == "3V") { Manager.Power = 3; } break; case "ANALOG": Manager.Connect1 = 1; socket = other.gameObject; Manager.parent = other.gameObject; break; case "INPUT": Manager.Connect1 = 1; if (other.name == "EPPlus") { Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <LEDManager>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <LEDManager>().Pause); pm = other.GetComponent <EPPlus>(); Manager.type = GameManager.SensorType.Led; } else if (other.name == "EPMinus") { Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <LEDManager>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <LEDManager>().Pause); pm = other.GetComponent <EPMinus>(); } else if (other.name == "LegMin") { Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <SoundParent>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <SoundParent>().Pause); pm = other.GetComponent <SoundGND>(); } else if (other.name == "LegIO") { Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <SoundParent>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <SoundParent>().Pause); pm = other.GetComponent <SoundDigital>(); Manager.type = GameManager.SensorType.Sound; } else if (other.name == "LegPlus") { Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <SoundParent>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <SoundParent>().Pause); pm = other.GetComponent <SoundVCC>(); } else if (other.name == "UltPinVCC") { Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <UltValue>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <UltValue>().Pause); pm = other.GetComponent <UltVCC>(); } else if (other.name == "UltPinSig") { Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <UltValue>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <UltValue>().Pause); pm = other.GetComponent <UltSig>(); Manager.ultRead = other.gameObject.GetComponentInParent <UltValue>().Read; // Manager.type = GameManager.SensorType.Ult; } else if (other.name == "UltPinEcho") { Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <UltValue>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <UltValue>().Pause); pm = other.GetComponent <UltEcho>(); Manager.ultRead = other.gameObject.GetComponentInParent <UltValue>().Read; Manager.type = GameManager.SensorType.Ult; } else if (other.name == "UltPinGND") { Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <UltValue>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <UltValue>().Pause); pm = other.GetComponent <UltGND>(); } else if (other.name == "DCPinPlus") { Manager.parent = other.gameObject; Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <DCPlus>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <DCPlus>().Pause); l298ndigi = other.GetComponent <DCPlus>(); Manager.type = GameManager.SensorType.DC; } else if (other.name == "DCPinMin") { Manager.parent = other.gameObject; Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <DCMin>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <DCMin>().Pause); l298ndigi = other.GetComponent <DCMin>(); } else if (other.name == "TempMin") { pm = other.GetComponent <TempHumiGND>(); } else if (other.name == "TempDig") { pm = other.GetComponent <TempHumiDigital>(); Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <TempHumiParent>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <TempHumiParent>().Pause); // ==========새로 만든 코드 ===============// Manager.type = GameManager.SensorType.HumiTemp; Manager.humitempRead = other.gameObject.GetComponentInParent <TempHumiParent>().Read; } else if (other.name == "TempPlus") { pm = other.GetComponent <TempHumiVCC>(); } else if (other.name == "IllPinOUT") { pm = other.GetComponent <IllOUT>(); Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <lightSensor>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <lightSensor>().Pause); //// ==== 새로 만든 코드 ======// Manager.type = GameManager.SensorType.Lux; Manager.luxRead = other.gameObject.GetComponentInParent <lightSensor>().Read; } else if (other.name == "IllPinVCC") { pm = other.GetComponent <IllVCC>(); } else if (other.name == "IllPinGND") { pm = other.GetComponent <IllGND>(); } else if (other.name == "SignalPin") //수위센서 { pm = other.GetComponent <WaterSig>(); Manager.run = new LineManager.RunDelegate(other.gameObject.GetComponentInParent <WaterValue>().Run); Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent <WaterValue>().Pause); Manager.type = GameManager.SensorType.water; Manager.waterRead = other.gameObject.GetComponentInParent <WaterValue>().Read; } else if (other.name == "PlusPin") { pm = other.GetComponent <WaterVcc>(); } else if (other.name == "MinusPin") { pm = other.GetComponent <WaterGnd>(); } break; case "OUTPUT": Manager.Connect1 = 1; if (other.name == "SubPinSig") { Manager.servorun = new LineManager.RunServo(other.gameObject.GetComponentInParent <ServoManager>().Run); // Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent<SpinSub>().Pause); pm = other.GetComponent <SubSig>(); Manager.type = GameManager.SensorType.Servo; } else if (other.name == "SubPinPlus") { Manager.servorun = new LineManager.RunServo(other.gameObject.GetComponentInParent <ServoManager>().Run); // Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent<SpinSub>().Pause); pm = other.GetComponent <SubPlus>(); } else if (other.name == "SubPinMin") { Manager.servorun = new LineManager.RunServo(other.gameObject.GetComponentInParent <ServoManager>().Run); // Manager.pause = new LineManager.PauseDelegate(other.gameObject.GetComponentInParent<SpinSub>().Pause); pm = other.GetComponent <SubMin>(); } break; case "L298N_OUT": Manager.Connect1 = 1; l298n = other.GetComponent <L298NOUT4>(); Manager.L298N_OUTCONNECT = true; break; case "L298N_GND": Manager.Connect1 = 1; l298n_gnd = other.GetComponent <L298N_GND>(); break; case "L298N_VCC": Manager.Connect1 = 1; if (other.name == "12V") { l298n_vcc12 = other.GetComponent <L298N_VCC12v>(); } else if (other.name == "5V") { l298n_vcc5 = other.GetComponent <L298N_VCC5v>(); } break; case "L298N_DIGITAL": if (other.name == "OUT1PIN") { l298ndigi = other.GetComponent <L298N_DIGITAL>(); Manager.run = new LineManager.RunDelegate(l298ndigi.Run); Manager.pause = new LineManager.PauseDelegate(l298ndigi.Pause); Manager.type = GameManager.SensorType.l298n; } else if (other.name == "OUT2PIN") { l298ndigi = other.GetComponent <L298N_DIGITAL2>(); Manager.run = new LineManager.RunDelegate(l298ndigi.Run); Manager.pause = new LineManager.PauseDelegate(l298ndigi.Pause); Manager.type = GameManager.SensorType.l298n; } else if (other.name == "OUT3PIN") { l298ndigi = other.GetComponent <L298N_DIGITAL3>(); Manager.run = new LineManager.RunDelegate(l298ndigi.Run); Manager.pause = new LineManager.PauseDelegate(l298ndigi.Pause); Manager.type = GameManager.SensorType.l298n; } else if (other.name == "OUT4PIN") { l298ndigi = other.GetComponent <L298N_DIGITAL4>(); Manager.run = new LineManager.RunDelegate(l298ndigi.Run); Manager.pause = new LineManager.PauseDelegate(l298ndigi.Pause); Manager.type = GameManager.SensorType.l298n; } break; case "BreadPin": Manager.Connect1 = 1; //Manager.parent = other.gameObject; Manager.plusGroup = other.gameObject.GetComponentInParent <PlusGroup>(); pm = other.GetComponent <BreadBoardPin>(); Manager.type = GameManager.SensorType.Bread; break; case "BreadDIGITAL": Manager.Connect1 = 1; Manager.parent = other.gameObject; Manager.plusGroup = other.gameObject.GetComponentInParent <PlusGroup>(); pm = other.GetComponent <BreadBoardPin>(); Manager.type = GameManager.SensorType.Bread; break; case "BreadGND": Manager.Connect1 = 1; Manager.parent = other.gameObject; Manager.plusGroup = other.gameObject.GetComponentInParent <PlusGroup>(); pm = other.GetComponent <BreadBoardPin>(); break; case "BreadPlus": Manager.Connect1 = 1; Manager.parent = other.gameObject; Manager.plusGroup = other.gameObject.GetComponentInParent <PlusGroup>(); pm = other.GetComponent <BreadBoardPin>(); break; case "resister": Manager.Connect1 = 1; resi = other.GetComponentInParent <Resist>(); if (Manager.parent == null) { //저항이랑 모터 빵판 등등 연결되었을때 Manager.parent = other.gameObject; } else if (Manager.parent.tag == "DIGITAL") { if (resi != null) { //저항이랑 DIGITAL이 연결되었을떄 if (resi.run != null) { Manager.run = new LineManager.RunDelegate(resi.run); } if (resi.servorun != null) { Manager.servorun = new LineManager.RunServo(resi.servorun); } if (resi.plusgroup != null) { Manager.plusGroup = resi.plusgroup; } } } break; } }
public virtual void SetUp() { _challenge = new PlusMinus(); }
public void Initialize() { _plusMinus = new PlusMinus(); }
public static void Main() { using (RenderFrame frame = RenderFrame.Create("", 640, 480, 32, false)) { Counter timer = new Counter(); Setup.basicOpenGL(); FileSystem fs = new FileSystem(); fs.addDefaultRoots("pretty good", "simple test"); MediaLoader loader = new MediaLoader(fs); //Texture sample = loader.fetch<Texture>("sample.bmp"); bool running = true; World world = World.Load(loader, "level01.lvl"); //world.add(new MeshInstance(loader.fetch<Mesh>("basicroad.obj"))); Camera cam = new Camera(); //Gl.glLoadIdentity(); float delta = 0; Key rightleft = new PlusMinus(new Hold(new Ckey(Keys.D)), new Hold(new Ckey(Keys.A))); Key forback = new PlusMinus(new Hold(new Ckey(Keys.W)), new Hold(new Ckey(Keys.S))); Key updown = new PlusMinus(new Hold(new Ckey(Keys.Space)), new Hold(new Ckey(Keys.ControlKey))); Hold sprint = new Hold(new Ckey(Keys.ShiftKey)); frame.setCursorPos(frame.Center); vec2 mousesmooth = new vec2(0, 0); vec3 movement = new vec3(0, 0, 0); float sensitivity = 0.1f; float mousesmoothing = 6; Pipeline pipe = Pipeline.Create("pipeline.xml", loader, frame.Width, frame.Height); while (running) { timer.Start(); Application.DoEvents(); /*fbo.updateTexture(delegate() * { * world.render(frame.Width, frame.Height, cam); * });*/ frame.begin(); pipe.render(new RenderArgs(world, cam, frame.Width, frame.Height)); /*Shader.Bind(shader); * FullscreenQuad.render(fbo, frame.Width, frame.Height); * Shader.Unbind();*/ frame.swap(); /*frame.begin(); * world.render(frame.Width, frame.Height, cam); * frame.swap();*/ System.Drawing.Point p = frame.getCursorPos(); System.Drawing.Point center = frame.Center; frame.setCursorPos(center); mousesmooth = vec2.Curve(new vec2(p.X - center.X, p.Y - center.Y), mousesmooth, mousesmoothing); movement = vec3.Curve(Key.Combine(rightleft, updown, forback).Normalized *(3 + sprint.Value * 3), movement, 5); // math::Quaternion(math::op::vec3::yAxisPositive, -x) * math::Quaternion(mRotation.getRight(), y) * mRotation; quat final = quat.FpsQuat(cam.rotation, mousesmooth.x * sensitivity, mousesmooth.y * sensitivity); cam.location += cam.rotation.getRUI(movement) * delta; cam.rotate(final); foreach (RenderFrame.Event e in frame.Events) { System.Diagnostics.Debug.WriteLine(e); if (e.button.equals(new Ckey(Keys.Escape))) { running = false; } else { Key.Run(e.button, e.down, rightleft, forback, updown, sprint); } } timer.Stop(); delta = timer.Duration; } } }