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
32 changes: 16 additions & 16 deletions Tasks/HelpClasses/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Tasks.HelpClasses
{
public class Repository
{
public List<Student> Students;
public List<student> Students;
public List<Product> Products;

public Repository()
Expand All @@ -14,22 +14,22 @@ public Repository()
Products = GetProducts();
}

private static List<Student> GetStudents()
private static List<student> GetStudents()
{
List<Student> students = new List<Student>();

students.Add(new Student(1, $"Student1", new DateTime(2020, 1, 1)));
students.Add(new Student(2, $"Student2", new DateTime(2010, 1, 1)));
students.Add(new Student(3, $"Student3", new DateTime(2011, 1, 1)));
students.Add(new Student(4, $"Student4", new DateTime(2012, 1, 1)));
students.Add(new Student(5, $"Student5", new DateTime(2013, 1, 1)));
students.Add(new Student(6, $"Student6", new DateTime(2014, 1, 1)));
students.Add(new Student(7, $"Student7", new DateTime(2015, 1, 1)));
students.Add(new Student(8, $"Student8", new DateTime(2016, 1, 1)));
students.Add(new Student(9, $"Student9", new DateTime(2017, 1, 1)));
students.Add(new Student(10, $"Student10", new DateTime(2018, 1, 1)));
students.Add(new Student(11, $"Student11", new DateTime(2019, 1, 1)));
students.Add(new Student(12, $"Student12", new DateTime(2020, 10, 31)));
List<student> students = new List<student>();

students.Add(new student(1, $"Student1", new DateTime(2020, 1, 1)));
students.Add(new student(2, $"Student2", new DateTime(2010, 1, 1)));
students.Add(new student(3, $"Student3", new DateTime(2011, 1, 1)));
students.Add(new student(4, $"Student4", new DateTime(2012, 1, 1)));
students.Add(new student(5, $"Student5", new DateTime(2013, 1, 1)));
students.Add(new student(6, $"Student6", new DateTime(2014, 1, 1)));
students.Add(new student(7, $"Student7", new DateTime(2015, 1, 1)));
students.Add(new student(8, $"Student8", new DateTime(2016, 1, 1)));
students.Add(new student(9, $"Student9", new DateTime(2017, 1, 1)));
students.Add(new student(10, $"Student10", new DateTime(2018, 1, 1)));
students.Add(new student(11, $"Student11", new DateTime(2019, 1, 1)));
students.Add(new student(12, $"Student12", new DateTime(2020, 10, 31)));

return students;
}
Expand Down
4 changes: 2 additions & 2 deletions Tasks/HelpClasses/Student.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Tasks.HelpClasses
{
public class Student
public class student
{
public Student(int id, string name, DateTime birth)
public student(int id, string name, DateTime birth)
{
Id = id;
Name = name;
Expand Down
7 changes: 6 additions & 1 deletion Tasks/Task1.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;

namespace Tasks
{
Expand All @@ -7,6 +8,10 @@ public class Task1
/*
* Dada a lista de inteiros, retorne o maior número da lista
*/
public static int? GetMax(List<int> list) { }
public static int? GetMax(List<int> list) {
var valmax = list.Max();
return valmax;
}
}
}

42 changes: 40 additions & 2 deletions Tasks/Task2.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Tasks
using System.Linq;
using System.Text.RegularExpressions;

namespace Tasks
{
public class Task2
{
Expand All @@ -20,6 +23,41 @@ public class Task2
* 3 - abc1324
* 4 - az111W
*/
public static bool CheckInput(string input) { }
public static bool CheckInput(string input)
{

int upcase = 0;
int lowcase = 0;
int num = 0;
bool result = false;


for (int i = 0; i < input.Length; i++)
{
char ch = input[i];
if (ch >= 'A' && ch <= 'Z')
upcase++;
else if (ch >= 'a' && ch <= 'z')
lowcase++;
else if (ch >= '0' && ch <= '9')
num++;
if (upcase >= 3)
{
if (lowcase >= 1)
{
if (num >= 4)
{
result = true;
}
}
}
else
result = false;
}return result;
}
}
}




18 changes: 16 additions & 2 deletions Tasks/Task3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ public class Task3
* Dada a lista de inteiros, retorne o somatório de todos os itens com valor POSITIVO da lista
* LEMBRANDO que 0 (zero) NÃO é um número positivo
*/
public static int GetSum(List<int> list) { }
}
public static int GetSum(List<int> list)
{

int sum = 0;
foreach (int item in list)
{
if (item > 0) {
sum = item +sum;


}

}
return sum;
}
}
}
15 changes: 13 additions & 2 deletions Tasks/Task4.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Tasks.HelpClasses;

namespace Tasks
Expand All @@ -9,6 +11,15 @@ public class Task4
* Desenvolva um método que retorne todos os estudantes do Repositório que nasceram em 2020
* Dica: A classe Repository possui as informções dos Students
*/
public static List<Student> GetStudentsByBirth() { }
public static List<student> GetStudentsByBirth()
{
var repository = new Repository();
List<student> students = new List<student>();
var result = Enumerable.Range(0, students.Count)
.Select(id => students[id].Birth.Year == 2020)
.ToList();
return result;

}
}
}
24 changes: 23 additions & 1 deletion Tasks/Task5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ public class Task5
*Crie um método que receba um inteiro e retorne "impar" caso seja impar e "par" caso seja par
*Caso o número seja 0 (zero), retorne "zero"
*/
public static string GetEvenOrOdd(int number) { }
public static string GetEvenOrOdd(int number)
{
string result = "";

if (number % 2 == 0)
{
result = ("par");
}



if (number % 2 != 0)
{
result = ("impar");
}

if (number == 0)
{
result = ("zero");
}

return result;
}
}
}
22 changes: 21 additions & 1 deletion Tasks/Task6.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ public class Task6
* 0.333333
* 0.166667
*/
public static List<decimal> GetRatios(List<int> numbers) { }
public static List<decimal> GetRatios(List<int> numbers) {
int i = 0;
int negnum = 0;
int zeronum = 0;
int posnum = 0;
for (i = 0; i <= numbers.Count; i++)
{
if (numbers[i] > 0)
posnum = posnum / negnum / zeronum;
numbers.Add(posnum);
if (numbers[i] < 0)
negnum = negnum / posnum / zeronum;
numbers.Add(negnum);
if (numbers[i] == 0)
zeronum = zeronum / negnum / posnum;
numbers.Add(zeronum);

}
return numbers.ConvertAll(x => (decimal)x);

}
}
}
15 changes: 10 additions & 5 deletions Tasks/Task7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@ public class Task7
* Desenvolma um método que retorne o nome dos produtos que estão com estoque zerado
* Dica: A classe Repository possui as informções dos Products
*/
public static List<string> GetProductsOutOfStock() { }

public static List<string> GetProductsOutOfStock() {
return null;
}
/*
* 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() { }

public static int GetSumStock()
{
return 0;
}
/*
* Crie um método que verifique, dado Id e quantidade solicitada do produto
* se o mesmo possui quantidade em estoque para venda
* Dica: A classe Repository possui as informções dos Products
*
*/
public static bool IsSalePossible(int productId, int orderQuantity) { }
public static bool IsSalePossible(int productId, int orderQuantity) {
return false;
}
}
}
1 change: 1 addition & 0 deletions Tasks/Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
4 changes: 4 additions & 0 deletions Tasks/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Collections" version="4.3.0" targetFramework="net472" />
</packages>