From 3ccac0cf7f22bdbd89216b4c5e8563ec81bf86c3 Mon Sep 17 00:00:00 2001 From: lucasrosate Date: Wed, 11 Nov 2020 16:49:46 -0300 Subject: [PATCH 1/3] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20feita=20em=2011/11/20?= =?UTF-8?q?20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestDotNetVrSystem/Task1.cs | 9 ++++++- TestDotNetVrSystem/Task2.cs | 21 +++++++++++++++- TestDotNetVrSystem/Task3.cs | 8 +++++++ TestDotNetVrSystem/Task4.cs | 14 +++++++++++ TestDotNetVrSystem/Task5.cs | 9 +++++++ TestDotNetVrSystem/Task6.cs | 43 ++++++++++++++++++++++++++++++++- TestDotNetVrSystem/Task7.cs | 48 ++++++++++++++++++++++++++++++++++++- 7 files changed, 148 insertions(+), 4 deletions(-) diff --git a/TestDotNetVrSystem/Task1.cs b/TestDotNetVrSystem/Task1.cs index 29e6e56..b4747f7 100644 --- a/TestDotNetVrSystem/Task1.cs +++ b/TestDotNetVrSystem/Task1.cs @@ -8,7 +8,14 @@ public class Task1 * Dada a lista de inteiros, retorne o maior número da lista */ public static int? GetMax(List list) - { + { int max = 0; + int i; + + for (i = 0; i < list.Count; i++) { + if(max < list[i]) max = list[i]; + } + + return max; } } } diff --git a/TestDotNetVrSystem/Task2.cs b/TestDotNetVrSystem/Task2.cs index 9c4fd22..0888e7b 100644 --- a/TestDotNetVrSystem/Task2.cs +++ b/TestDotNetVrSystem/Task2.cs @@ -1,4 +1,6 @@ -namespace TestDotNetVrSystem + +using System; +namespace TestDotNetVrSystem { public class Task2 { @@ -21,6 +23,23 @@ public class Task2 */ public static bool CheckInput(string input) { + int i; + + if(input.Length > 7) return false; + + for( i =0; i< input.Length; i++ ) { + + if ( (i <= 2 && Char.IsDigit(input[i]) ) || (Char.IsLower(input[i]))) { + return false; + } + + if (i > 2 && Char.IsLetter(input[i])) { + return false; + } + } + + return true; + } } } diff --git a/TestDotNetVrSystem/Task3.cs b/TestDotNetVrSystem/Task3.cs index d49024f..9ddea6c 100644 --- a/TestDotNetVrSystem/Task3.cs +++ b/TestDotNetVrSystem/Task3.cs @@ -10,6 +10,14 @@ public class Task3 */ public static int GetSum(List list) { + int sum = 0; + int i; + + for (i=0; i< list.Count; i++) { + if (list[i] > 0) sum+= list[i]; + } + + return sum; } } } diff --git a/TestDotNetVrSystem/Task4.cs b/TestDotNetVrSystem/Task4.cs index 826350e..b4171c6 100644 --- a/TestDotNetVrSystem/Task4.cs +++ b/TestDotNetVrSystem/Task4.cs @@ -10,6 +10,20 @@ public class Task4 */ public static List GetStudentsByBirth() { + Repository Repo = new Repository(); + List studentsThisYear = new List(); + int i; + int year = 2020; + + + for (i=0; i< Repo.Students.Count; i++) + if(Repo.Students[i].Birth.Year == year) + studentsThisYear.Add(Repo.Students[i]); + + + return studentsThisYear; + + } } } diff --git a/TestDotNetVrSystem/Task5.cs b/TestDotNetVrSystem/Task5.cs index 8f08577..75f3c25 100644 --- a/TestDotNetVrSystem/Task5.cs +++ b/TestDotNetVrSystem/Task5.cs @@ -8,6 +8,15 @@ public class Task5 */ public static string GetEvenOrOdd(int number) { + if (number == 0) { + return "zero"; + } + else if (number % 2 == 0) { + return "par"; + } + else { + return "impar"; + } } } } diff --git a/TestDotNetVrSystem/Task6.cs b/TestDotNetVrSystem/Task6.cs index 7fc72b1..8dcb869 100644 --- a/TestDotNetVrSystem/Task6.cs +++ b/TestDotNetVrSystem/Task6.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; - +using System; namespace TestDotNetVrSystem { public class Task6 @@ -17,6 +17,47 @@ public class Task6 */ public static List GetRatios(List numbers) { + int positiveCount = 0; + int negativeCount = 0; + int zeroCount = 0; + + double positiveRatio; + double negativeRatio; + double zeroRatio; + + + List listRatios = new List(); + int i; + + int listLength = numbers.Count; + + for (i = 0; i < listLength; i++) + { + if (numbers[i] == 0) + { + zeroCount += 1; + + } + else if (numbers[i] > 0) + { + positiveCount += 1; + } + else + { + negativeCount += 1; + } + } + + positiveRatio = (double) positiveCount / listLength; + negativeRatio = (double) negativeCount / listLength; + zeroRatio = (double) zeroCount / listLength; + + listRatios.Add((decimal) Math.Round(positiveRatio, 6)); + listRatios.Add((decimal) Math.Round(negativeRatio, 6)); + listRatios.Add((decimal) Math.Round(zeroRatio, 6)); + + return listRatios; + } } } diff --git a/TestDotNetVrSystem/Task7.cs b/TestDotNetVrSystem/Task7.cs index 601eb24..a73d099 100644 --- a/TestDotNetVrSystem/Task7.cs +++ b/TestDotNetVrSystem/Task7.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; - +using TestDotNetVrSystem.HelpClasses; namespace TestDotNetVrSystem { public class Task7 @@ -10,14 +10,42 @@ public class Task7 */ public static List GetProductsOutOfStock() { + int i; + Repository Repo = new Repository(); + List productsOutofStock = new List(); + + + for (i = 0; i < Repo.Products.Count; i++) + { + if (Repo.Products[i].Stock.Quantity == 0) + { + productsOutofStock.Add(Repo.Products[i].Name); + } + } + + return productsOutofStock; } + + /* * Desenvolma um método que retorne a soma total das quantidades de estoque dos itens * Dica: A classe Repository possui as informções dos Products */ public static int GetSumStock() { + int i; + int sumQuantity = 0; + Repository Repo = new Repository(); + + + for (i = 0; i < Repo.Products.Count; i++) + { + sumQuantity += Repo.Products[i].Stock.Quantity; + } + + + return sumQuantity; } /* @@ -28,6 +56,24 @@ public static int GetSumStock() */ public static bool IsSalePossible(int productId, int orderQuantity) { + int i; + Repository Repo = new Repository(); + + + for (i = 0; i < Repo.Products.Count; i++) + { + if (productId == Repo.Products[i].Id) + if (Repo.Products[i].Stock.Quantity >= orderQuantity) + { + return true; + } else + { + return false; + } + } + + + return false; } } } From 216c29799bb14984a8ccb78d1843c8d3a163335b Mon Sep 17 00:00:00 2001 From: lucasrosate Date: Wed, 11 Nov 2020 17:05:15 -0300 Subject: [PATCH 2/3] =?UTF-8?q?altera=C3=A7=C3=A3o=20feita=2011/11/2020?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestDotNetVrSystem/Task2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestDotNetVrSystem/Task2.cs b/TestDotNetVrSystem/Task2.cs index 0888e7b..a22ed76 100644 --- a/TestDotNetVrSystem/Task2.cs +++ b/TestDotNetVrSystem/Task2.cs @@ -29,7 +29,7 @@ public static bool CheckInput(string input) for( i =0; i< input.Length; i++ ) { - if ( (i <= 2 && Char.IsDigit(input[i]) ) || (Char.IsLower(input[i]))) { + if (i <= 2 && (Char.IsDigit(input[i]) || (Char.IsLower(input[i])))) { return false; } From ff9ee3a054cd729ce6e13193de12953f787953df Mon Sep 17 00:00:00 2001 From: lucasrosate Date: Wed, 11 Nov 2020 17:13:10 -0300 Subject: [PATCH 3/3] =?UTF-8?q?altera=C3=A7=C3=A3o=20feita?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestDotNetVrSystem/Task2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestDotNetVrSystem/Task2.cs b/TestDotNetVrSystem/Task2.cs index a22ed76..157f59b 100644 --- a/TestDotNetVrSystem/Task2.cs +++ b/TestDotNetVrSystem/Task2.cs @@ -25,7 +25,7 @@ public static bool CheckInput(string input) { int i; - if(input.Length > 7) return false; + if(input.Length != 7) return false; for( i =0; i< input.Length; i++ ) {