protected void like_Click(object sender, EventArgs e) { LikesManager likesManager = new LikesManager(); CalculationManager calculationManager = new CalculationManager(); int UserId = int.Parse(((Session["user"] as User).Id).ToString()); int ProjectId = int.Parse(Request.QueryString["Id"]); Model.Likes likes = likesManager.GetModelByUserIdAndProjectId(UserId, ProjectId); if (likes == null) { if (likesManager.Insert(UserId, ProjectId) > 0 && calculationManager.LikeCountAddition(ProjectId) > 0) { Response.Write("<script>alert('关注成功!!');loaction.href='Projectinfo.aspx';</script>"); this.like.Text = "取消关注"; Response.Write("<script> window.location.href = document.URL; </script>"); } else { Response.Write("<script>alert('关注失败!!');</script>"); } } else { if (likesManager.Delete(UserId, ProjectId) > 0 && calculationManager.LikeCountSubtraction(ProjectId) > 0) { Response.Write("<script>alert('已取消关注!!');</script>"); this.like.Text = "关注"; Response.Write("<script> window.location.href = document.URL; </script>"); } else { Response.Write("<script>alert('取消失败!!');</script>"); } } }
public ActionResult Calculate(FormCollection form) { decimal totalSalary = 0M; decimal toalTaxPaid = 0M; int remainingMonths = 0; for (int index = 1; index <= 12; ++index) { decimal salary = Convert.ToDecimal(form["salary" + index.ToString()]); totalSalary += salary; decimal taxPaid = Convert.ToDecimal(form["taxpaid" + index.ToString()]); //assuming that remaining periods means the non tax paid months. if (taxPaid == 0M) { remainingMonths++; } toalTaxPaid += taxPaid; } totalSalary += Convert.ToDecimal(form["salaryextra"]); TaxComputation report = CalculationManager.GetMonthlyTax( totalSalary, toalTaxPaid, remainingMonths); ViewBag.TaxPerMonth = report.TaxPerMonth; ViewBag.TotalTaxLiability = report.TotalTaxLiability; ViewBag.TaxPaid = report.TaxPaid; ViewBag.TotalIncome = report.TotalSalary; ViewBag.RemainingPeriods = report.RemainingPeriods; return(View()); }
public void SelectCalculationStrategy_returnsAEEICalculationType_true(PackagedSolutionId packID) { var package = new PackageFactory().GetPackage(packID); var calcManager = new CalculationManager(); Assert.IsTrue(typeof(IEEICalculation).IsAssignableFrom(calcManager.SelectCalculationStrategy(package)[0].GetType())); }
public void SelectCalculationStrategyDoesNotReturnWrong(PackagedSolutionId packID) { var package = new PackageFactory().GetPackage(packID); var calcManager = new CalculationManager(); Assert.AreNotEqual(typeof(BoilerAsPrimary), calcManager.SelectCalculationStrategy(package)[0].GetType()); }
protected void Page_Load(object sender, EventArgs e) { ProjectManager projectManager = new ProjectManager(); int UserId = (Session["user"] as Model.User).Id; CalculationManager calculationManager = new CalculationManager(); Session["SumOfProject"] = calculationManager.SumOfProject(); Session["SumOfCurrentMoney"] = calculationManager.SumOfCurrentMoney(); Session["SumOfSupportProjects"] = calculationManager.SumOfSupportProjects(); if (Request["State"] == null || int.Parse(Request["State"]) == 2) { this.RepeaterOfProjectInfo.DataSource = projectManager.GetModelById(UserId); } else if (int.Parse(Request["State"]) == 1) { this.RepeaterOfProjectInfo.DataSource = projectManager.GetModelByIdAndState(UserId, 1); } else { this.RepeaterOfProjectInfo.DataSource = projectManager.GetModelByIdAndState(UserId, 0); } if (Request["Like"] != null) { this.RepeaterOfProjectInfo.DataSource = projectManager.GetProjectUserLikes(UserId); } if (Request["Support"] != null) { this.RepeaterOfProjectInfo.DataSource = projectManager.GetProjectUserSupport(UserId); } if (Request["Launch"] != null) { this.RepeaterOfProjectInfo.DataSource = projectManager.GetProjectUserLaunch(UserId); } DataBind(); }
private IEnumerator ProcessOptimalLine(string graphName, AeroPredictor vessel, Conditions conditions, float exitSpeed, float exitAlt, float initialSpeed, float initialAlt, CostIncreaseFunction costIncreaseFunc, Predicate <float> neighborPredicate, float[,] predicateData, CostIncreaseFunction timeDifferenceFunc) { CalculationManager singleUseManager = new CalculationManager(); LineGenData lineGenData = new LineGenData(singleUseManager, vessel, conditions, exitSpeed, exitAlt, initialSpeed, initialAlt, costIncreaseFunc, neighborPredicate, predicateData, timeDifferenceFunc); ThreadPool.QueueUserWorkItem(OptimalLineTask, lineGenData); while (!singleUseManager.Completed) { yield return(0); } List <AscentPathPoint> results = (List <AscentPathPoint>)lineGenData.state.Result; if (timeDifferenceFunc != costIncreaseFunc) { ((MetaLineGraph)graphables[graphName]).SetValues(results.Select(pt => new Vector2(pt.speed, pt.altitude)).ToArray(), new float[][] { results.Select(pt => pt.climbAngle * Mathf.Rad2Deg).ToArray(), results.Select(pt => pt.climbRate).ToArray(), results.Select(pt => pt.cost).ToArray(), results.Select(pt => pt.time).ToArray() }); } else { ((MetaLineGraph)graphables[graphName]).SetValues(results.Select(pt => new Vector2(pt.speed, pt.altitude)).ToArray(), new float[][] { results.Select(pt => pt.climbAngle * Mathf.Rad2Deg).ToArray(), results.Select(pt => pt.climbRate).ToArray(), results.Select(pt => pt.cost).ToArray() }); } //this.GetOptimalPath(vessel, conditions, 1410, 17700, 0, 0, fuelToClimb, f => f > 0, excessP).Select(pt => new Vector2(pt.speed, pt.altitude)).ToArray()); //((LineGraph)graphables["Time-Optimal Path"]).SetValues( //this.GetOptimalPath(vessel, conditions, 1410, 17700, 0, 0, timeToClimb, f => f > 0, excessP).Select(pt => new Vector2(pt.speed, pt.altitude)).ToArray()); singleUseManager.Dispose(); }
public ActionResult Calculate(FormCollection form) { decimal totalSalary = 0M; decimal toalTaxPaid = 0M; int remainingMonths = 0; for (int index = 1; index <= 12; ++index) { totalSalary += Convert.ToDecimal(form["salary" + index.ToString()]); decimal taxPaid = Convert.ToDecimal(form["taxpaid" + index.ToString()]); if (taxPaid == 0M) { remainingMonths += 1; } toalTaxPaid += taxPaid; } totalSalary += Convert.ToDecimal(form["salaryextra"]); TaxComputation result = CalculationManager.GetMonthlyTax( totalSalary, toalTaxPaid, remainingMonths); //tcc ViewBag.TotalSalary = result.TotalSalary; ViewBag.RemainingPeriods = result.RemainingPeriods; ViewBag.TaxPaid = result.TaxPaid; ViewBag.TotalTaxLiability = result.TotalTaxLiability; ViewBag.TaxPerMonth = result.TaxPerMonth; return(View()); }
private static void SetupInBackground(object obj) { GenData rootData = (GenData)obj; Conditions conditions = rootData.conditions; CalculationManager manager = rootData.storeState.manager; CalculationManager seedManager = new CalculationManager(); CalculationManager.State[,] results = null; Conditions seedConditions = new Conditions(conditions.body, conditions.lowerBoundSpeed, conditions.upperBoundSpeed, 11, conditions.lowerBoundAltitude, conditions.upperBoundAltitude, 11); GenerateLevel(seedConditions, seedManager, ref results, rootData.vessel); if (!seedManager.WaitForCompletion(30000)) { Debug.LogError("KerbalWindTunnel: Seed data timed out!"); return; } seedManager.Dispose(); GenerateLevel(conditions, manager, ref results, rootData.vessel); if (rootData.storeState.manager.Cancelled) { return; } rootData.storeState.StoreResult(results); }
public GenData(AeroPredictor vessel, Conditions conditions, float speed, CalculationManager manager) { this.vessel = vessel; this.conditions = conditions; this.speed = speed; this.storeState = manager.GetStateToken(); }
public void SelectCalculationStrategyReturnsSecondCalc(PackagedSolutionId packID) { var package = new PackageFactory().GetPackage(packID); var calcManager = new CalculationManager(); Assert.AreEqual(typeof(BoilerForWater), calcManager.SelectCalculationStrategy(package)[1].GetType()); }
public IEnumerator Enemy2Turn() { Debug.Log(unitData.currentHp); if (unitData.currentHp <= 0) { BattleSystemClass.gameState = GameState.PLAYERTURN; BattleSystemClass.unitState = UnitState.KNIGHT; UIManager.EnableKnightSkillBar(); } _enemyStartingPosition = enemyGO.transform.position; int randomPlayerUnitIndex = Random.Range(0, UIManager.playerUnitGOs.Count); GameObject attackedPlayerGO = UIManager.playerUnitGOs[randomPlayerUnitIndex]; Unit attackedPlayerUnit = attackedPlayerGO.GetComponent <Unit> (); Vector3 playerPos = attackedPlayerGO.transform.position; AnimationManager.PlayAnim("Dash", 5); enemyGO.transform.Translate(-Time.deltaTime * 1000, 0, 0, CameraTransform); if (Vector3.Distance(enemyGO.transform.position, playerPos) < unitData.errorDistance) { enemyGO.transform.position = new Vector3(playerPos.x + 2f, playerPos.y, playerPos.z); } yield return(new WaitForSeconds(0.5f)); //StartCoroutine(CameraManager.MoveTowardsTarget(attackedPlayerGO)); AnimationManager.PlayAnim("Attack", 5); AudioManager.PlaySound("basicAttack"); AnimationManager.PlayAnim("Hit", randomPlayerUnitIndex); //calculate damage float damageDone = CalculationManager.CalculateDamage(unitData); bool isDead = CalculationManager.DealDamage(damageDone, attackedPlayerUnit); //damagePopup GameObject cloneTextGO = Instantiate(unitData.floatingDamagePrefab, attackedPlayerGO.transform.position + unitData.damageOffset, Quaternion.identity); UIManager.DamagePopup(damageDone, unitData, cloneTextGO); UIManager.SetPlayerUnitHp(attackedPlayerUnit.unitData.currentHp, randomPlayerUnitIndex); AudioManager.PlaySound("hurtSound"); yield return(new WaitForSeconds(0.5f)); AnimationManager.PlayAnim("Idle", randomPlayerUnitIndex); enemyGO.transform.position = _enemyStartingPosition; AnimationManager.PlayAnim("Idle", 5); if (isDead) { AudioManager.PlaySound("KnightDeath"); AnimationManager.PlayAnim("Dead", randomPlayerUnitIndex); } BattleSystemClass.gameState = GameState.PLAYERTURN; BattleSystemClass.unitState = UnitState.KNIGHT; UIManager.EnableKnightSkillBar(); }
internal CalculatorPanel() { InitializeComponent(); calculationManager = new CalculationManager(this, CultureInfo.CurrentCulture); calculationTextBox.Font = ConfigUtil.GetFontParameter("FontInUse"); calcTextBox.Font = ConfigUtil.GetFontParameter("FontInUse"); }
/// <summary> /// Recalculates the EnergyLabel property of this object. /// </summary> public void UpdateEei() { var calculations = CalculationManager.SelectCalculationStrategy(this); foreach (var calculation in calculations ?? Enumerable.Empty <IEEICalculation>()) { EnergyLabel.Add(calculation?.CalculateEEI(this)); } }
public void SelectCalculationStrategyReturnsCorrectEEI(PackagedSolutionId packID, float expectedValue) { var package = new PackageFactory().GetPackage(packID); var calcManager = new CalculationManager(); EEICalculationResult Results = calcManager.SelectCalculationStrategy(package)[0].CalculateEEI(package); //Assert.AreEqual(Results.EEI, expectedValue); Assert.IsTrue(Results.EEI <= expectedValue + 1 && Results.EEI >= expectedValue - 1); }
public void SelectCalculationStrategyReturnsCorrectSolEff(PackagedSolutionId packID, float expectedValue) { var package = new PackageFactory().GetPackage(packID); var calcManager = new CalculationManager(); EEICalculationResult Results = calcManager.SelectCalculationStrategy(package)[0].CalculateEEI(package); //Assert.AreEqual(Results.SolarHeatContribution, expectedValue); Assert.IsTrue(Results.SolarHeatContribution <= expectedValue + 0.1f && Results.SolarHeatContribution >= expectedValue - 0.1f); }
/// <summary> /// Calculate single value /// </summary> /// <param name="collection"></param> /// <returns></returns> public override RelativeStrengthIndicator Calculate(IIndexCollection <IPointModel> collection) { var currentPoint = collection.ElementAtOrDefault(collection.Count - 1); if (currentPoint == null) { return(this); } var positives = new List <double>(Interval); var negatives = new List <double>(Interval); for (var i = 1; i <= Interval; i++) { var nextPrice = collection.ElementAtOrDefault(collection.Count - i); var previousPrice = collection.ElementAtOrDefault(collection.Count - i - 1); if (nextPrice != null && previousPrice != null) { positives.Add(Math.Max(nextPrice.Bar.Close.Value - previousPrice.Bar.Close.Value, 0.0)); negatives.Add(Math.Max(previousPrice.Bar.Close.Value - nextPrice.Bar.Close.Value, 0.0)); } } var averagePositive = CalculationManager.SimpleAverage(positives, positives.Count - 1, Interval); var averageNegative = CalculationManager.SimpleAverage(negatives, negatives.Count - 1, Interval); var average = ConversionManager.Compare(averageNegative, 0) ? 1.0 : averagePositive / averageNegative; var nextValue = 100.0 - 100.0 / (1.0 + average); var nextIndicatorPoint = new PointModel { Time = currentPoint.Time, TimeFrame = currentPoint.TimeFrame, Last = nextValue, Bar = new PointBarModel { Close = nextValue } }; var previousIndicatorPoint = Values.ElementAtOrDefault(collection.Count - 1); if (previousIndicatorPoint == null) { Values.Add(nextIndicatorPoint); } Values[collection.Count - 1] = nextIndicatorPoint; currentPoint.Series[Name] = currentPoint.Series.TryGetValue(Name, out IPointModel seriesItem) ? seriesItem : new RelativeStrengthIndicator(); currentPoint.Series[Name].Bar.Close = currentPoint.Series[Name].Last = nextIndicatorPoint.Bar.Close; currentPoint.Series[Name].Time = currentPoint.Time; currentPoint.Series[Name].ChartData = ChartData; Last = Bar.Close = currentPoint.Series[Name].Bar.Close; return(this); }
private void bindGv() { CalculationManager cm = new CalculationManager(); //List<Calculation> c = cm.getCalculations("joey"); List <Calculation> c = cm.getCalculations(Session["Username"].ToString()); gvData.DataSource = c; gvData.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { ProjectManager projectManager = new ProjectManager(); CalculationManager calculationManager = new CalculationManager(); projectManager.OverDate(); this.EnableViewState = false; Session["SumOfProject"] = calculationManager.SumOfProject(); Session["SumOfCurrentMoney"] = calculationManager.SumOfCurrentMoney(); Session["SumOfSupportProjects"] = calculationManager.SumOfSupportProjects(); ClassifyManager classifyManager = new ClassifyManager(); this.TypeList.DataSource = classifyManager.GetAllList(); int pageIndex; int pageSize = 16; if (!int.TryParse(Request["pageIndex"], out pageIndex)) { pageIndex = 1; } int pageCount = projectManager.GetPageCount(pageSize); PageCount = pageCount; pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > pageCount ? pageCount : pageIndex; PageIndex = pageIndex; string keyword = Request.QueryString["KeyWords"]; this.ProjectList.DataSource = projectManager.GetPageList(PageIndex, pageSize, keyword); string id = Request["classifyId"]; int classifyId = Session["classifyId"] == null ? 0 : Convert.ToInt32(Session["classifyId"]); ProjectState state = Session["state"] == null ? ProjectState.Null : (ProjectState)Enum.Parse(typeof(ProjectState), Session["state"].ToString()); if (ProjectState.TryParse(Request["state"], out state) | int.TryParse(Request["classifyId"], out classifyId)) { State = state; ClassifyId = classifyId; Session["classifyId"] = classifyId; Session["state"] = state; PageCount = projectManager.GetPageCount(classifyId, state, pageSize); pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > PageCount ? PageCount : pageIndex; PageIndex = pageIndex; this.ProjectList.DataSource = projectManager.GetPageListForState(PageIndex, pageSize, classifyId, state); } else { PageCount = projectManager.GetPageCount(pageSize); pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > PageCount ? PageCount : pageIndex; PageIndex = pageIndex; this.ProjectList.DataSource = projectManager.GetPageList(PageIndex, pageSize, keyword); } DataBind(); }
public IEnumerator KnightBasicAttack(int enemyID, GameObject enemyToAttackGO) { Unit attackedEnemyUnit = enemyToAttackGO.GetComponent <Unit> (); Vector3 enemyPos = enemyToAttackGO.transform.position; BattleSystemClass.gameState = GameState.WAITING; AudioManager.PlaySound("KnightOpeners"); Vector2 startingPos = knightGO.transform.position; AnimationManager.PlayAnim("Dash", 0); knightGO.transform.Translate(Time.deltaTime * 1000, 0, 0, CameraTransform); if (Vector3.Distance(knightGO.transform.position, enemyPos) < unitData.errorDistance) { knightGO.transform.position = new Vector3(enemyPos.x - 2f, enemyPos.y, enemyPos.z); } //StartCoroutine(CameraManager.MoveTowardsTarget(enemyToAttackGO)); yield return(new WaitForSeconds(0.5f)); AnimationManager.PlayAnim("Attack", 0); AudioManager.PlaySound("basicAttack"); //calculate damage float damageDone = CalculationManager.CalculateDamage(unitData); bool isDead = CalculationManager.DealDamage(damageDone, attackedEnemyUnit); //damagePopup GameObject cloneTextGO = Instantiate(unitData.floatingDamagePrefab, enemyPos + unitData.damageOffset, Quaternion.identity); UIManager.DamagePopup(damageDone, unitData, cloneTextGO); UIManager.SetEnemyHp(attackedEnemyUnit.unitData.currentHp, enemyID); AnimationManager.PlayAnim("Hit", enemyID); AudioManager.PlaySound("hurtSound"); yield return(new WaitForSeconds(0.5f)); AnimationManager.PlayAnim("Idle", enemyID); knightGO.transform.position = startingPos; AnimationManager.PlayAnim("Idle", 0); if (isDead) { //play animation on attacked enemy AnimationManager.PlayAnim("Dead", enemyID); //observer.NotifyUnitDeath (enemyID); UnitDied(enemyID); //check if there is an alive enemy } //Warrior's turn starts BattleSystemClass.gameState = GameState.PLAYERTURN; BattleSystemClass.unitState = UnitState.WARRIOR; UIManager.DisableKnightSkillBar(); UIManager.EnableWarriorSkillBar(); }
protected void gridviewShoppingCart_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { _totalcounter += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "TotalPrice")); } labelSubTotal.Text = string.Format("{0:c}", _totalcounter); labelTax.Text = string.Format("{0:c}", (CalculationManager.CalcSalesTax(_totalcounter))); }
private void Result_Click(object sender, EventArgs e) { if (_info.Operation != Operations.Sqrt && _info.Operation != Operations.Reciprocal) { _info.SecondNumber = float.Parse(Input.Text, CultureInfo.InvariantCulture.NumberFormat); } var doOperation = new Operation(CalculationManager.GetOperation(_info.Operation)); SetInput(doOperation(_info.FirstNumber, _info.SecondNumber), x => Input.Text = x); }
public void SelectCalculationStrategyReturnsCorrectSupHeat(PackagedSolutionId packID, float expectedValue) { var package = new PackageFactory().GetPackage(packID); var calcManager = new CalculationManager(); EEICalculationResult Results = calcManager.SelectCalculationStrategy(package)[0].CalculateEEI(package); //Assert.AreEqual(Results.EffectOfSecondaryHeatPump, expectedValue); // fejl margin hævet til 0.3 fordi det eneste der påvirker resultatet en en værdi der er 0.509 i stedet for 0.504 Assert.IsTrue(Results.EffectOfSecondaryHeatPump <= expectedValue + 0.3f && Results.EffectOfSecondaryHeatPump >= expectedValue - 0.3f); }
/// <summary> /// Gvive the data selected index changed. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> protected void gvData_SelectedIndexChanged(object sender, EventArgs e) { CalculationManager cm = new CalculationManager(); //List<Calculation> c = cm.getCalculations("joey"); List <Calculation> c = cm.getCalculations(Session["Username"].ToString()); Calculation ca = c[gvData.SelectedIndex]; Session["DetailObject"] = ca; Response.Redirect("CalculationResult.aspx"); }
public IEnumerator WarriorBasicAttack(int enemyID, GameObject enemyToAttackGO) { Unit enemyToAttackUnit = enemyToAttackGO.GetComponent <Unit> (); Vector3 enemyPos = enemyToAttackGO.transform.position; BattleSystemClass.gameState = GameState.WAITING; Vector2 startingPos = warriorGO.transform.position; AnimationManager.PlayAnim("Dash", 1); warriorGO.transform.Translate(Time.deltaTime * 1000, 0, 0, CameraTransform); if (Vector3.Distance(warriorGO.transform.position, enemyPos) < unitData.errorDistance) { warriorGO.transform.position = new Vector3(enemyPos.x - 2f, enemyPos.y, enemyPos.z); } yield return(new WaitForSeconds(0.5f)); AnimationManager.PlayAnim("Attack", 1); AudioManager.PlaySound("basicAttack"); //StartCoroutine(CameraManager.MoveTowardsTarget(enemyToAttackGO)); //calculate damage float damageDone = CalculationManager.CalculateDamage(unitData); bool isDead = CalculationManager.DealDamage(damageDone, enemyToAttackUnit); //damagePopup GameObject floatingDamageGO = Instantiate(unitData.floatingDamagePrefab, enemyPos + unitData.damageOffset, Quaternion.identity); UIManager.DamagePopup(damageDone, unitData, floatingDamageGO); UIManager.SetEnemyHp(enemyToAttackUnit.unitData.currentHp, enemyID); AnimationManager.PlayAnim("Hit", enemyID); AudioManager.PlaySound("hurtSound"); yield return(new WaitForSeconds(1f)); AnimationManager.PlayAnim("Idle", enemyID); warriorGO.transform.position = startingPos; AnimationManager.PlayAnim("Idle", 1); if (isDead) { AnimationManager.PlayAnim("Dead", enemyID); UnitDied(enemyID); } BattleSystemClass.gameState = GameState.PLAYERTURN; BattleSystemClass.unitState = UnitState.WIZARD; UIManager.DisableWarriorSkillBar(); UIManager.EnableWizardSkillBar(); }
public static void RunTests() { // Test Case 1 - Random Data People[] Case01 = new People[10]; Case01[0] = new People(1900, 1930); Case01[1] = new People(1920, 1970); Case01[2] = new People(1947, 1998); Case01[3] = new People(1923, 1989); Case01[4] = new People(1953, 2000); Case01[5] = new People(1945, 1978); Case01[6] = new People(1902, 1930); Case01[7] = new People(1976, 1996); Case01[8] = new People(1945, 2000); Case01[9] = new People(1999, 2000); int answer01 = CalculationManager.CalculateMaxPopulatedYear(Case01, 1900, 2000); Debug.WriteLine("\n Case 01 Year With Max Population: {0} \n", answer01); // Test Case 2 - Data with Same Birth Year People[] Case02 = new People[10]; Case02[0] = new People(1920, 1930); Case02[1] = new People(1920, 1970); Case02[2] = new People(1920, 1998); Case02[3] = new People(1920, 1989); Case02[4] = new People(1920, 2000); Case02[5] = new People(1920, 1978); Case02[6] = new People(1920, 1930); Case02[7] = new People(1920, 1996); Case02[8] = new People(1920, 2000); Case02[9] = new People(1920, 2000); answer01 = CalculationManager.CalculateMaxPopulatedYear(Case02, 1900, 2000); Debug.WriteLine("\n Case 02 Year With Max Population: {0} \n", answer01); // Test Case 3 - Data with Same Death Year People[] Case03 = new People[10]; Case03[0] = new People(1910, 2000); Case03[1] = new People(1913, 2000); Case03[2] = new People(1900, 2000); Case03[3] = new People(1955, 2000); Case03[4] = new People(1934, 2000); Case03[5] = new People(1978, 2000); Case03[6] = new People(1992, 2000); Case03[7] = new People(1934, 2000); Case03[8] = new People(1987, 2000); Case03[9] = new People(1934, 2000); answer01 = CalculationManager.CalculateMaxPopulatedYear(Case03, 1900, 2000); Debug.WriteLine("\n Case 03 Year With Max Population: {0} \n", answer01); }
public void StartListening() { // Data buffer for incoming data. byte[] bytes = new Byte[1024 * 1024]; // Establish the local endpoint for the socket. // The DNS name of the computer // running the listener is "host.contoso.com". IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 12000); // Create a TCP/IP socket. Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); CalculationManager cm = new CalculationManager(); // Bind the socket to the local endpoint and listen for incoming connections. try { listener.Bind(localEndPoint); listener.Listen(8); while (true) { // Set the event to nonsignaled state. allDone.Reset(); // Start an asynchronous socket to listen for connections. Console.WriteLine("Waiting for a connection... port : " + 12000); listener.BeginAccept( new AsyncCallback(AcceptCallback), listener); allDone.WaitOne(); // Wait until a connection is made before continuing. Console.WriteLine("-------------------------------------"); } } catch (Exception e) { Console.WriteLine(e.ToString()); } Console.WriteLine("\nPress ENTER to continue..."); Console.Read(); }
public LineGenData(CalculationManager manager, AeroPredictor vessel, Conditions conditions, float exitSpeed, float exitAlt, float initialSpeed, float initialAlt, CostIncreaseFunction costIncreaseFunc, Predicate <float> neighborPredicate, float[,] predicateData, CostIncreaseFunction timeDifferenceFunc) { this.state = manager.GetStateToken(); this.vessel = vessel; this.conditions = conditions; this.exitSpeed = exitSpeed; this.exitAlt = exitAlt; this.initialSpeed = initialSpeed; this.initialAlt = initialAlt; this.costIncreaseFunc = costIncreaseFunc; this.timeDifferenceFunc = timeDifferenceFunc; this.neighborPredicate = neighborPredicate; this.predicateData = predicateData; }
/// <summary> /// Calculate single value /// </summary> /// <param name="collection"></param> /// <returns></returns> public override MovingAverageIndicator Calculate(IIndexCollection <IPointModel> collection) { var currentPoint = collection.ElementAtOrDefault(collection.Count - 1); if (currentPoint == null) { return(this); } var pointPrice = currentPoint.Bar.Close; switch (Mode) { case MovingAverageEnum.Bid: pointPrice = currentPoint.Bid; break; case MovingAverageEnum.Ask: pointPrice = currentPoint.Ask; break; } var nextIndicatorPoint = new PointModel { Last = pointPrice, Time = currentPoint.Time, TimeFrame = currentPoint.TimeFrame, Bar = new PointBarModel { Close = pointPrice } }; var previousIndicatorPoint = Values.ElementAtOrDefault(collection.Count - 1); if (previousIndicatorPoint == null) { Values.Add(nextIndicatorPoint); } Values[collection.Count - 1] = nextIndicatorPoint; var average = CalculationManager.LinearWeightAverage(Values.Select(o => o.Bar.Close.Value), Values.Count - 1, Interval); currentPoint.Series[Name] = currentPoint.Series.TryGetValue(Name, out IPointModel seriesItem) ? seriesItem : new MovingAverageIndicator(); currentPoint.Series[Name].Bar.Close = currentPoint.Series[Name].Last = ConversionManager.Compare(average, 0) ? nextIndicatorPoint.Bar.Close : average; currentPoint.Series[Name].Time = currentPoint.Time; currentPoint.Series[Name].ChartData = ChartData; Last = Bar.Close = currentPoint.Series[Name].Bar.Close; return(this); }
//protected CameraManager CameraManager; #endregion protected virtual void Awake() { AnimationManager = GetComponent <AnimationManager> (); UIManager = GetComponent <UIManager> (); BattleSystemClass = GetComponent <BattleSystem> (); CalculationManager = GetComponent <CalculationManager> (); TurnManager = GetComponent <TurnManager> (); if (!(Camera.main is null)) { CameraTransform = Camera.main.transform; } //CameraManager = GetComponent<CameraManager>(); unitData.currentHp = unitData.maxHp; }
private static void ContinueInBackground(object obj) { object[] inObj = (object[])obj; GenData rootData = (GenData)inObj[0]; CalculationManager.State[,] results = (CalculationManager.State[, ])inObj[1]; CalculationManager manager = rootData.storeState.manager; GenerateLevel(rootData.conditions, manager, ref results, rootData.vessel); if (rootData.storeState.manager.Cancelled) { return; } rootData.storeState.StoreResult(results); }
private void DefinirFormulas() { #region Calculos comunes _calcManagerComun = CalculationManager<DatosProyecto>.Create(); _calcManagerComun.AfterFormulaExecution += CalcManager_AfterFormulaExecution; //Cant Dias = Horas Totales / Horas x Día _calcManagerComun.DefineFormula(x => x.Dias, x => (x.HorasTotales.ConvertirADecimal(0) / x.HorasPorDia.ConvertirADecimal()).ConvertirAString()); // %Evento = 1 / Cant Eventos _calcManagerComun.DefineFormula(x => x.PorcentajeEvento, x => (1 / x.CantidadEventos.ConvertirADecimal()).ConvertirAString(Formatos.FormatoPorcentajeConDecimales)); // Horas/Evento = Horas Totales / Cant Eventos _calcManagerComun.DefineFormula(x => x.HorasEvento, x => (x.HorasTotales.ConvertirADecimal(0) / x.CantidadEventos.ConvertirADecimal()).ConvertirAString()); //El Precio Bruto = Honorarios / (1-Factor o Tasa) + Gastos _calcManagerComun.DefineFormula(x => x.PrecioBruto, x => ((x.Honorarios.ConvertirADecimal(0) / (1 - x.Factor.ConvertirADecimal(0))) + x.Gastos.ConvertirADecimal(0)).ConvertirAString(Formatos.FormatoEntero)); #endregion #region Calculos de Hs #region Calculo de Hs - Tipo 1 _calcManagerHsTotales1 = CalculationManager<DatosProyecto>.Create() //Horas Totales = Cant Cursos * (Dias de la semana * Horas x Dia + Cant Participantes * Horas x Correccion) .DefineFormula(x => x.HorasTotales, x => (x.CantidadEventos.ConvertirADecimal(0) * (x.DiasPorSemana.ConvertirADecimal(0) * x.HorasPorDia.ConvertirADecimal(0) + x.CantidadParticipantes.ConvertirADecimal(0) * x.HorasCorreccion.ConvertirADecimal(0))).ConvertirAString()); _calcManagerHsTotales1.AfterFormulaExecution += CalcManager_AfterFormulaExecution; #endregion #region Calculo de Hs - Tipo 2 //TODO: Unificar con HsTotales1 (+ HorasAdicionales) _calcManagerHsTotales2 = CalculationManager<DatosProyecto>.Create() //Horas Totales = Cant Talleres * (Dias de la semana * Horas x Dia + Cant a corregir * Horas x Corrección) + Horas de customizado .DefineFormula(x => x.HorasTotales, x => ((x.CantidadEventos.ConvertirADecimal(0) * (x.DiasPorSemana.ConvertirADecimal(0) * x.HorasPorDia.ConvertirADecimal(0) + x.CantidadParticipantes.ConvertirADecimal(0) * x.HorasCorreccion.ConvertirADecimal(0))) + x.HorasAdicionales.ConvertirADecimal(0)).ConvertirAString()); _calcManagerHsTotales2.AfterFormulaExecution += CalcManager_AfterFormulaExecution; #endregion #region Calculo de Hs - Tipo 3 _calcManagerHsTotales3 = CalculationManager<DatosProyecto>.Create() //Horas Totales = Cant Eventos * Horas x Evento .DefineFormula(x => x.HorasTotales, x => (x.CantidadEventos.ConvertirADecimal(0) * x.HorasEventoIngresado.ConvertirADecimal(0)).ConvertirAString()); _calcManagerHsTotales3.AfterFormulaExecution += CalcManager_AfterFormulaExecution; #endregion #region Calculo de Hs - Tipo 4 _calcManagerHsTotales4 = CalculationManager<DatosProyecto>.Create() //Horas Totales= Cant Eventos*(DiasPorSemana * Horas x Dia +Cant participantes* Hs Corrección) .DefineFormula(x => x.HorasTotales, x => (x.CantidadEventos.ConvertirADecimal(0) * (x.DiasPorSemana.ConvertirADecimal(0) * x.HorasPorDia.ConvertirADecimal(0) + x.CantidadParticipantes.ConvertirADecimal(0) * x.HorasCorreccion.ConvertirADecimal(0))).ConvertirAString()); _calcManagerHsTotales4.AfterFormulaExecution += CalcManager_AfterFormulaExecution; #endregion #region Calculo de Hs - Tipo 5 _calcManagerHsTotales5 = CalculationManager<DatosProyecto>.Create(); //HoralTotales = HorasPorEventoIngresado _calcManagerHsTotales5.DefineFormula(x => x.HorasTotales, x => x.HorasEventoIngresado.ConvertirADecimal(0).ConvertirAString()); _calcManagerHsTotales5.AfterFormulaExecution += CalcManager_AfterFormulaExecution; #endregion #endregion #region Calculos de Honorarios #region Calculo de Honorarios - Tipo 1 _calcManagerPrecioBruto1 = CalculationManager<DatosProyecto>.Create() //Honorarios = Rate Fijo .DefineFormula(x => x.Honorarios, x => (x.RateFijo.ConvertirADecimal(0)).ConvertirAString(Formatos.FormatoEntero)); _calcManagerPrecioBruto1.AfterFormulaExecution += CalcManager_AfterFormulaExecution; #endregion #region Calculo de Honorarios - Tipo 2 _calcManagerPrecioBruto2 = CalculationManager<DatosProyecto>.Create() // Honorarios = ( Rate Fijo + Rate Variable* Cant. Personas adicionales )* Cant Cursos .DefineFormula(x => x.Honorarios, x => ((x.RateFijo.ConvertirADecimal(0) + (x.RateVariable.ConvertirADecimal(0) * CalcularParticipantesAdicionales(x.CantidadTopeRateFijo.ConvertirADecimal(0), x.CantidadParticipantes.ConvertirADecimal(0))) ) * x.CantidadEventos.ConvertirADecimal(0) ).ConvertirAString(Formatos.FormatoEntero)); _calcManagerPrecioBruto2.AfterFormulaExecution += CalcManager_AfterFormulaExecution; #endregion #region Calculo de Honorarios - Tipo 3 _calcManagerPrecioBruto3 = CalculationManager<DatosProyecto>.Create() //Honorarios = (Horas Totales * RateVariable) .DefineFormula(x => x.Honorarios, x => (x.HorasTotales.ConvertirADecimal(0) * x.RateVariable.ConvertirADecimal(0)).ConvertirAString(Formatos.FormatoEntero)); _calcManagerPrecioBruto3.AfterFormulaExecution += CalcManager_AfterFormulaExecution; #endregion #region Calculo de Honorarios - Tipo 4 _calcManagerPrecioBruto4 = CalculationManager<DatosProyecto>.Create() //Honorarios = (Cant Participantes * Precio x Participante* Cant Eventos) .DefineFormula(x => x.Honorarios, x => (x.CantidadParticipantes.ConvertirADecimal(0) * x.RateVariable.ConvertirADecimal(0) * x.CantidadEventos.ConvertirADecimal(0)).ConvertirAString(Formatos.FormatoEntero)); _calcManagerPrecioBruto4.AfterFormulaExecution += CalcManager_AfterFormulaExecution; #endregion #endregion }