Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion TestDotNetVrSystem/Task1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ public class Task1
* Dada a lista de inteiros, retorne o maior número da lista
*/
public static int? GetMax(List<int> list)
{
{ int max = 0;
int i;

for (i = 0; i < list.Count; i++) {
if(max < list[i]) max = list[i];
}

return max;
}
}
}
21 changes: 20 additions & 1 deletion TestDotNetVrSystem/Task2.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace TestDotNetVrSystem

using System;
namespace TestDotNetVrSystem
{
public class Task2
{
Expand All @@ -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;

}
}
}
8 changes: 8 additions & 0 deletions TestDotNetVrSystem/Task3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ public class Task3
*/
public static int GetSum(List<int> list)
{
int sum = 0;
int i;

for (i=0; i< list.Count; i++) {
if (list[i] > 0) sum+= list[i];
}

return sum;
}
}
}
14 changes: 14 additions & 0 deletions TestDotNetVrSystem/Task4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ public class Task4
*/
public static List<Student> GetStudentsByBirth()
{
Repository Repo = new Repository();
List <Student> studentsThisYear = new List<Student>();
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;


}
}
}
9 changes: 9 additions & 0 deletions TestDotNetVrSystem/Task5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
}
}
43 changes: 42 additions & 1 deletion TestDotNetVrSystem/Task6.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;

using System;
namespace TestDotNetVrSystem
{
public class Task6
Expand All @@ -17,6 +17,47 @@ public class Task6
*/
public static List<decimal> GetRatios(List<int> numbers)
{
int positiveCount = 0;
int negativeCount = 0;
int zeroCount = 0;

double positiveRatio;
double negativeRatio;
double zeroRatio;


List<decimal> listRatios = new List<decimal>();
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;

}
}
}
48 changes: 47 additions & 1 deletion TestDotNetVrSystem/Task7.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;

using TestDotNetVrSystem.HelpClasses;
namespace TestDotNetVrSystem
{
public class Task7
Expand All @@ -10,14 +10,42 @@ public class Task7
*/
public static List<string> GetProductsOutOfStock()
{
int i;
Repository Repo = new Repository();
List<string> productsOutofStock = new List<string>();


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;
}

/*
Expand All @@ -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;
}
}
}