static void Main(string[] args) { Func <Task1, string> TaskSolver = task => { float population = System.Single.Parse(task.City.Population); float sickPercentage = System.Single.Parse(task.City.SickPercentage); float letality = System.Single.Parse(task.Virus.KillProbability); int sickNumber = (int)(Math.Truncate(population * sickPercentage)); int deathNumber = (int)(Math.Truncate(population * sickPercentage * letality)); return($"There are {sickNumber} people sick with {task.Virus.Name} in the city of {task.City.Name}, {deathNumber} of which died"); }; Task1.CheckSolver(TaskSolver); }
private void writeAndExpect(string input, bool expectedOutput) { string filePath = Path.GetTempPath() + Guid.NewGuid().ToString() + ".txt"; File.WriteAllText(filePath, input); Task1 t = new Task1(); bool output = t.isPalindrome(filePath); Assert.IsTrue(File.Exists(filePath)); Assert.AreEqual(expectedOutput, output); File.Delete(filePath); }
static void Main(string[] args) { Func <Task1, string> TaskSolver = task => { // Your solution goes here // You can get all needed inputs from task.[Property] // Good luck! float sickPeople = float.Parse(task.City.Population) * float.Parse(task.City.SickPercentage); float deadPeople = sickPeople * float.Parse(task.Virus.KillProbability); return($"There are {Math.Truncate(sickPeople)} people sick with {task.Virus.Name} in the city of {task.City.Name}, {Math.Truncate(deadPeople)} of which died"); }; Task1.CheckSolver(TaskSolver); }
public void InsertNunTest() { Task1 item = new Task1(); var result = item.InsertNun(15, 15, 0, 0); int number = ConvertBitArrayToNumber(result); Assert.AreEqual(number, 15); result = item.InsertNun(8, 15, 0, 0); number = ConvertBitArrayToNumber(result); Assert.AreEqual(number, 9); result = item.InsertNun(8, 15, 3, 8); number = ConvertBitArrayToNumber(result); Assert.AreEqual(number, 120); }
private void AddTask1_Click_1(object sender, RoutedEventArgs e) { if (Task1.Text == "") { Add.Visibility = Visibility.Visible; grid2.Visibility = Visibility.Hidden; } else { Task task = new Task(); task.textBlock.Text = Task1.Text; l.Items.Add(task); Task1.Text = ""; Task1.Focus(); } }
static void Main() { int[] arr = { 142, 3432, 4234, 4, 32, 2332 }; long count = Task1.Compute(arr); int[,] matrix = { { 5222, 34, 34, 5, 23, 1 }, { 234, 543, 5345, 32, 2, 1 } }; Task2 calculate = new Task2(); long counter = calculate.CalculateCount(matrix); Task3 calc = new Task3(); long newCalculate = calc.CalcSum(matrix, 0); }
public async Task <ActionResult <string> > ResolveTask2([FromBody] Task1 lists) { try { var result = await _helper.GetResultTask2Async(lists.ElementsData); var key = Guid.NewGuid().ToString(); _keyResults.Add(key, result); return(Ok("\"" + key + "\"")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void SampleTest3() { int[] input1 = new int[] { 111, 321, 557 }; Task1 p = new Task1(); int[] output1 = p.filterPrimeNumbers(input1); int[] expectedOutput1 = new int[] { 557 }; Assert.AreEqual(1, output1.Length); for (int i = 0; i < 1; i++) { Assert.AreEqual(expectedOutput1[i], output1[i]); } }
public static void Main(string[] args) { ITask task; System.Console.WriteLine("It works!"); while (true) { System.Console.Clear(); System.Console.WriteLine( "Choice what task to run!\n" + "1. Task1 [Introduction to .net framework 4]\n" + "2. Task2 [Basic programming constructs]\n" + "Press \'e\' to exit"); System.Console.Write("select option: "); var consoleKey = System.Console.ReadKey().Key; System.Console.WriteLine(); switch (consoleKey) { case System.ConsoleKey.E: { System.Console.WriteLine(); return; } case System.ConsoleKey.D1: { task = new Task1(); task.Visualize(); break; } case System.ConsoleKey.D2: { task = new Task2(); task.Visualize(); break; } default: { System.Console.WriteLine(); break; } } } }
public void SampleTest1() { int[] input1 = new int[] { 1, 2, 3, 4, 5 }; Task1 p = new Task1(); int[] output1 = p.filterPrimeNumbers(input1); int[] expectedOutput1 = new int[] { 2, 3, 5 }; Assert.AreEqual(3, output1.Length); for (int i = 0; i < 3; i++) { Assert.AreEqual(expectedOutput1[i], output1[i]); } }
static void Main(string[] args) { while (true) { IOservice.ShowMessage ( "1 - TaskOne (conversion from grams)\n" + "2 - TaskTwo (converting bytes to kilo, mega, Giga)\n" + "3 - TaskThree (Centimeters to meters and kilometers)\n" + "4 - TaskFour (Swap values of variables without using an additional variable)\n" + "5 - TaskFive (the ratio of the cost of 1 kg of candy to 1 kg of gelatine)\n" + "exit - Exit the program" ); string command = IOservice.GetUserInputStr(); switch (command) { case "1": Task1.StartTask(); break; case "2": Task2.StartTask(); break; case "3": Task3.StartTask(); break; case "4": Task4.StartTask(); break; case "5": Task5.StartTask(); break; case "exit": return; default: IOservice.ShowMessage("Unknown command"); break; } } }
static void Main(string[] args) { AbstractTask App; App = new Task1(); App.Start(); App = new Task2(); App.Start(); App = new Task3(); App.Start(); App = new Task4(); App.Start(); App = new Task5(); App.Start(); }
static void Main(string[] args) { Func <Task1, string> TaskSolver = task => { //Andrii Nevidomyi solution //Example //[task.City.Name] = "Virtualiev" //[task.City.Population] = 1400 //[task.City.SickPercentage] = 0.3 //[task.Virus.Name] = "Hlomanda" //[task.Virus.KillProbability] = 0.2 //"There are 420 people sick with Hlomanda in the city of Virtualiev, 84 of which died" //------------------------------------------------------------------------------------ //parse float population, sickPersentage, killProbability; //result float sickPeople = 0, peopleDied = 0; try { population = Convert.ToSingle(task.City.Population); sickPersentage = Convert.ToSingle(task.City.SickPercentage); killProbability = Convert.ToSingle(task.Virus.KillProbability); sickPeople = population * sickPersentage; peopleDied = sickPeople * killProbability; } catch (FormatException) { Console.WriteLine("FormatException"); } return($"There are {Math.Truncate(sickPeople)} people sick with {task.Virus.Name} in the city of {task.City.Name}, {Math.Truncate(peopleDied)} of which died"); }; Task1.CheckSolver(TaskSolver); }
static void Main(string[] args) { Func <Task1, string> TaskSolver = task => { bool parsingSuccesful = float.TryParse(task.City.Population, out float population); parsingSuccesful &= float.TryParse(task.City.SickPercentage, out float sickPercentage); parsingSuccesful &= float.TryParse(task.Virus.KillProbability, out float killProbability); if (!parsingSuccesful) { throw new ArgumentException("Wasn't able to parse all of the string parameters containing floats!"); } float peopleInfected = MathF.Truncate(population * sickPercentage); float peopleDead = MathF.Truncate(peopleInfected * killProbability); return ($"There are {peopleInfected} people sick with {task.Virus.Name} in the city of {task.City.Name}, {peopleDead} of which died"); }; Task1.CheckSolver(TaskSolver); }
public void TestSingle() { string filePath = Path.GetTempPath() + Guid.NewGuid().ToString() + ".txt"; string input = "a"; File.WriteAllText(filePath, input); Task1 t = new Task1(); bool output = t.isPalindrome(filePath); Assert.IsTrue(File.Exists(filePath)); bool expectedOutput = true; Assert.AreEqual(expectedOutput, output); File.Delete(filePath); }
static void Main(string[] args) { Func <Task1, string> TaskSolver = task => { // Your solution goes here // You can get all needed inputs from task.[Property] // Good luck! float numberOfSickPeople = float.Parse(task.City.Population) * float.Parse(task.City.SickPercentage); float numberOfDeath = float.Parse(task.Virus.KillProbability) * numberOfSickPeople; string answer = "There are " + Math.Truncate(numberOfSickPeople) + " people sick with " + task.Virus.Name + " in the city of " + task.City.Name + ", " + Math.Truncate(numberOfDeath) + " of which died"; return(answer); }; Task1.CheckSolver(TaskSolver); }
public ActionResult Show(int id) { Task1 task = db.Tasks.Find(id); var selectList = new List <SelectListItem>(); selectList.Add(new SelectListItem { Value = "1", Text = "Not started" }); selectList.Add(new SelectListItem { Value = "2", Text = "In progress" }); selectList.Add(new SelectListItem { Value = "3", Text = "Done" }); ViewBag.Statuses = selectList; var comments = db.Comments; var goodComments = new List <Comment>(); foreach (var comment in comments) { if (comment.TaskId == task.TaskId) { goodComments.Add(comment); } } ViewBag.Comments = goodComments; // ViewBag.Members = GetAllUsers(); return(View(task)); }
private static void DoTask1AndTask2() { List <Person> persons = Task1.GetListPersons(); foreach (var person in persons) { Console.WriteLine($"Name: {person.Name}, Age: {person.Age}"); } Task2.AddRangePersons(ref persons); foreach (var person in persons) { Console.Write("Numbers: "); foreach (var number in person.PhoneNumbers) { Console.Write(number + " "); } Console.WriteLine(); } }
static void Main(string[] args) { Func <Task1, string> TaskSolver = task => { int population = int.Parse(task.City.Population); float sickPercentage = float.Parse(task.City.SickPercentage); float killProbability = float.Parse(task.Virus.KillProbability); float sickPopulation = (float)population * sickPercentage; int sickPopulationInt = (int)Math.Truncate(sickPopulation); float diedPopulation = killProbability * sickPopulation; int diedPopulationInt = (int)Math.Truncate(diedPopulation); string result = $"There are {sickPopulationInt} people sick with {task.Virus.Name} in the city of {task.City.Name}, {diedPopulationInt} of which died"; return(result); }; Task1.CheckSolver(TaskSolver); }
public void TestDeserialize() { string someXML = "<complex xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<a>5</a>" + "<b>8</b>" + "</complex>"; string filePath = Path.GetTempPath() + Guid.NewGuid().ToString() + ".xml"; File.WriteAllText(filePath, someXML); Task1 t = new Task1(); ComplexNumber outputNumber = t.deserializeNumber(filePath); Assert.IsNotNull(outputNumber, "deserialized number is null!"); Assert.AreEqual(outputNumber.a, 5); Assert.AreEqual(outputNumber.b, 8); File.Delete(filePath); }
static void Main(string[] args) { Func <Task1, string> TaskSolver = task => { // Your solution goes here // You can get all needed inputs from task.[Property] // Good luck! string cityName = task.City.Name; string popul = task.City.Population; string sickPerc = task.City.SickPercentage; string virusName = task.Virus.Name; string killProb = task.Virus.KillProbability; float sickNum = float.Parse(popul) * float.Parse(sickPerc); float diedNum = float.Parse(killProb) * sickNum; return($"There are {Math.Truncate(sickNum)} people sick with {virusName} in the city of {cityName}, {Math.Truncate(diedNum)} of which died"); }; Task1.CheckSolver(TaskSolver); }
static void Main(string[] args) { Task1 task1 = new Task1(); Console.WriteLine("Old string"); task1.print_str(); task1.word_replacement(); Console.WriteLine("New string"); task1.print_str(); Task2 task2 = new Task2(); Console.WriteLine("Old string"); task2.print(); task2.character_replacement(); Console.WriteLine("New string"); task2.print(); Task3 task3 = new Task3(); task3.print(); Console.ReadKey(); }
static void Main(string[] args) { Func <Task1, string> TaskSolver = task => { if (float.TryParse(task.City.SickPercentage, out float sickPercentage) && float.TryParse(task.Virus.KillProbability, out float killProbability) && int.TryParse(task.City.Population, out int population)) { float numberOfSick = population * sickPercentage; float numberOfKilledPeople = numberOfSick * killProbability; double roundedNumberOfSick = MathF.Truncate(numberOfSick); double roundedNumberKilledPeople = MathF.Truncate(numberOfKilledPeople); return($"There are {roundedNumberOfSick} people sick with {task.Virus.Name} in the city of {task.City.Name}, {roundedNumberKilledPeople} of which died"); } return("Error: Wrong data"); }; Task1.CheckSolver(TaskSolver); }
public ActionResult New(Task1 task) { try { if (ModelState.IsValid) { db.Tasks.Add(task); db.SaveChanges(); TempData["message"] = "Task added!"; return(RedirectToAction("Index")); } else { return(View(task)); } } catch (Exception e) { return(View(task)); } }
static void Main(string[] args) { try { Console.WriteLine("Enter natural number"); string text = Console.ReadLine(); uint number = Task1.ParseNaturalFromString(text); if (Task1.AreDigitsDifferent(number) == true) { Console.WriteLine("All digits in the number are different"); } else { Console.WriteLine("Not all digits in the number are different"); } } catch (ArgumentOutOfRangeException e) { Console.WriteLine(e.Message); } }
private static void RunTasks() { Console.WriteLine("Testing a Single Task"); //Testing a single Task Task1 t1 = new Task1(); // TRACE < DEBUG < INFO < WARN < ERROR < FATAL t1.LoggingLevel = LogLevel.Info; //optional setting. Default is 'Trace' logging t1.Number1 = 4; t1.Number2 = 5; t1.Run(null); Console.WriteLine("\nTesting Task Chaining"); //Task Chaining Task2 t2 = new Task2(); t2.Number1 = 10; t2.LoggingLevel = LogLevel.Trace; t2.Run(t1.Run(null)); //passes output of t1 to t2. You can have any number of tasks in Task Chaining }
public ActionResult Edit(int id, Task1 requiredTask) { try { if (ModelState.IsValid) { if (requiredTask.TaskEndDate < requiredTask.TaskStartDate) { TempData["message"] = "You cannot finish a task before you start it!"; return(RedirectToAction("New")); } Task1 task = db.Tasks.Find(id); if (TryUpdateModel(task)) { task.TaskTitle = requiredTask.TaskTitle; task.TaskDescription = requiredTask.TaskDescription; task.TaskStartDate = requiredTask.TaskStartDate; task.TaskEndDate = requiredTask.TaskEndDate; task.TaskStatus = requiredTask.TaskStatus; task.MemberId = requiredTask.MemberId; task.Member = db.Users.Find(requiredTask.MemberId); db.SaveChanges(); id = task.TaskId; } return(RedirectToAction("Show", "Task1", new { id })); } else { return(View(requiredTask)); } } catch { return(View()); } }
// Start is called before the first frame update void Awake() { SelectorNode root = new SelectorNode(); SequenceNode seq1 = new SequenceNode(); Task1 task1 = new Task1(sc, pl); Task2 task2 = new Task2(sc, pl); seq1.addChild(task1); seq1.addChild(task2); SequenceNode seq2 = new SequenceNode(); Task3 task3 = new Task3(sc, osc); Task4 task4 = new Task4(sc, osc); seq2.addChild(task3); seq2.addChild(task4); SelectorNode sel2 = new SelectorNode(); SequenceNode seq3 = new SequenceNode(); Task5 task5 = new Task5(sc); Task6 task6 = new Task6(sc); seq3.addChild(task5); seq3.addChild(task6); Task7 task7 = new Task7(sc); sel2.addChild(seq3); sel2.addChild(task7); root.addChild(seq1); root.addChild(seq2); root.addChild(sel2); behavior = new BehaviorTree(root); sc.SetDestination(sc.transform.position); }
static void Main(string[] args) { Func <Task1, string> TaskSolver = task => { // Your solution goes here // You can get all needed inputs from task.[Property] // Good luck! float population = Single.Parse(task.City.Population); float sickPercentage = Single.Parse(task.City.SickPercentage); float killProbability = Single.Parse(task.Virus.KillProbability); float sickValue = population * sickPercentage; float deadValue = sickValue * killProbability; string answer = "There are " + Math.Truncate(sickValue) + " people sick with " + task.Virus.Name + " in the city of " + task.City.Name + ", " + Math.Truncate(deadValue) + " of which died"; return(answer); }; Task1.CheckSolver(TaskSolver); }
static void Main(string[] args) { Func <Task1, string> TaskSolver = task => { // Your solution goes here // You can get all needed inputs from task.[Property] // Good luck! float cityPopulation = float.Parse(task.City.Population); float sickPercentage = float.Parse(task.City.SickPercentage); float deathRate = float.Parse(task.Virus.KillProbability); float sickPeopleCount = cityPopulation * sickPercentage; float deadPeopleCount = sickPeopleCount * deathRate; string result = $"There are {Math.Truncate(sickPeopleCount)}" + $" people sick with {task.Virus.Name} in the city of {task.City.Name}," + $" {Math.Truncate(deadPeopleCount)} of which died"; return(result); }; Task1.CheckSolver(TaskSolver); }
public void Unregister(Task1.Clock.Clock clock) { clock.Alarm -= Do; }
public void Register (Task1.Clock.Clock clock) { clock.Alarm += Do; }