# ligas **NOME:** João gabriel Camargo Ramos **TURMA:** Informática C. ## TREINO FOCADO A ```csharp= using System; using System.Collections.Generic; // Treino 1 public class Retangulo { public double Base { get; set; } public double Altura { get; set; } } public class Notas { public double Nota1 { get; set; } public double Nota2 { get; set; } public double Nota3 { get; set; } } public class TreinoFocadoA { public List<int> GerarSequencia1 (int fim) { List<int> seq = new List<int>(); for( int i = 0; i <= fim; i ++ ) { seq.Add(i); } return seq; } public List<int> GerarSequencia2 (int inicio, int fim) { List<int> seq = new List<int>(); for( int i = inicio ; i <= fim; i ++ ) { seq.Add(i); } return seq; } public List<int> GerarSequenciaPares (int inicio, int final) { List<int> seq = new List<int>(); for( int i = inicio; i <= final; i++ ) { if (i % 2 == 0) { seq.Add(i); } } return seq; } public int SomarAte (int fim) { int x = 0; for( int i = 0; i < fim; i++ ) { x += i; } return x; } public double CalcularMedia (List<double> notas) { double soma = 0; for ( int i = 0; i < notas.Count; i++ ) { double nota = notas [i]; soma = soma + nota; } double media = soma/ notas.Count; return media; } public List<double> CalcularMedias (List<Notas> notas) { List<double> medias = new List<double>(); for (int i = 0; i < notas.Count; i++) { Notas notasAl = notas[i]; double media = (notasAl.Nota1 + notasAl.Nota2 + notasAl.Nota3)/ notas.Count; medias.Add(media); } return medias; } public List<double> CalcularQuadrados (List<double> numeros) { List<double> quadrados = new List<double>(); for(int i = 0; i < numeros.Count; i++) { double num = numeros[i]; double pot = Math.Pow(num,2); quadrados.Add(pot); } return quadrados; } private double AreaRetangulo (Retangulo retangulo) { return retangulo.Base * retangulo.Altura; } public List<double> AreaRetangulos (List<Retangulo> retangulos) { List<double> areas = new List<double>(); for ( int i = 0; i < retangulos.Count; i++ ) { Retangulo abcd = retangulos[i]; double areaFinal = AreaRetangulo(abcd); areas.Add(areaFinal); } return areas; } } Retangulo a = new Retangulo(); a.Altura = 10; a.Base = 5; Retangulo b = new Retangulo (); b.Altura = 5; b.Base = 8; Retangulo c = new Retangulo (); c.Base = 2; c.Altura = 3; Notas d = new Notas(); d.Nota1 = 8; d.Nota2 = 9; d.Nota3 = 10; Notas e = new Notas (); e.Nota1 = 10; e.Nota2 = 10; e.Nota3 = 10; Notas f = new Notas (); f.Nota1 = 5; f.Nota2 = 9; f.Nota3 = 8; Notas g = new Notas (); g.Nota1 = 5; g.Nota2 = 5; g.Nota3 = 5; List<Retangulo> h = new List<Retangulo>(); h.Add(a); h.Add(b); h.Add(c); List<Notas> i = new List<Notas>(); i.Add(d); i.Add(e); i.Add(f); i.Add(g); TreinoFocadoA j = new TreinoFocadoA(); List<int> k = new List<int>(); k = j.GerarSequencia1(3); List<int> l = new List<int>(); l = j.GerarSequencia2(2,12); List<int> m = new List<int>(); m = j.GerarSequenciaPares(0,10); int n = j.SomarAte(10); List<double> o = new List<double>(); o = j.AreaRetangulos(h); List<double> p = new List<double>(); p = j.CalcularMedias(i); double q = j.CalcularMedia(p); Console.WriteLine(string.Join(" - ", k)); Console.WriteLine(string.Join(" - ", l)); Console.WriteLine(string.Join(" - ", m)); Console.WriteLine(string.Join(" - ", n)); Console.WriteLine(string.Join(" - ", o)); Console.WriteLine(string.Join(" - ", p)); Console.WriteLine(string.Join(" - ", q)); //0 - 1 - 2 - 3 //2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 //0 - 2 - 4 - 6 - 8 - 10 //45 //50 - 40 - 6 //6,75 - 7,5 - 5,5 - 3,75 //5,875 ``` ## TREINO FOCADO B ```csharp= using System; using System.Collections.Generic; // Treino 2 public class Pessoa { public string Nome { get; set; } public DateTime Nascimento { get; set; } } public class TreinoFocadoB { public List<DateTime> GerarSequencia1 (int qtd) { DateTime inicio = DateTime.Now; List<DateTime> lista = new List<DateTime>(); for ( int i = 0; i < qtd; i++ ) { lista.Add(inicio); inicio = inicio.AddDays(1); } return lista; } public List<DateTime> GerarSequencia2 (int qtd, DateTime data) { List<DateTime> lista = new List<DateTime>(); for ( int i = 0; i < qtd; i++ ) { lista.Add(data); data = data.AddDays(1); } return lista; } public List<DateTime> GerarSequenciaNumerosPares (int qtd, DateTime data) { List<DateTime> lista = new List<DateTime>(); for (int i = 0; i < qtd; i++) { if(data.Day % 2 == 0) { lista.Add(data); } else { i--; } data = data.AddDays(1); } return lista; } private string QualSigno (DateTime nascimento) { DateTime aquario1 = new DateTime(nascimento.Year,01,22); DateTime aquario2 = new DateTime(nascimento.Year,02,18); DateTime peixes1 = new DateTime(nascimento.Year,02,19); DateTime peixes2 = new DateTime(nascimento.Year,03,19); DateTime aries1 = new DateTime(nascimento.Year,03,20); DateTime aries2 = new DateTime(nascimento.Year,04,20); DateTime touro1 = new DateTime(nascimento.Year,04,21); DateTime touro2 = new DateTime(nascimento.Year,05,20); DateTime gemeos1 = new DateTime(nascimento.Year,05,21); DateTime gemeos2 = new DateTime(nascimento.Year,06,20); DateTime cancer1 = new DateTime(nascimento.Year,06,21); DateTime cancer2 = new DateTime(nascimento.Year,07,21); DateTime leao1 = new DateTime(nascimento.Year,07,22); DateTime leao2 = new DateTime(nascimento.Year,08,22); DateTime virgem1 = new DateTime(nascimento.Year,08,23); DateTime virgem2 = new DateTime(nascimento.Year,09,22); DateTime libra1 = new DateTime(nascimento.Year,09,23); DateTime libra2 = new DateTime(nascimento.Year,10,22); DateTime escorpiao1 = new DateTime(nascimento.Year,10,23); DateTime escorpiao2 = new DateTime(nascimento.Year,11,21); DateTime sagitario1 = new DateTime(nascimento.Year,11,22); DateTime sagitario2 = new DateTime(nascimento.Year,12,21); string signo = string.Empty; if (nascimento >= aquario1 && nascimento <= aquario2) signo = "Aquário"; else if (nascimento >= peixes1 && nascimento <= peixes2) signo = "Peixes"; else if (nascimento >= aries1 && nascimento <= aries2) signo = "Áries"; else if (nascimento >= touro1 && nascimento <= touro2) signo = "Touro"; else if (nascimento >= gemeos1 && nascimento <= gemeos2) signo = "Gêmeos"; else if (nascimento >= cancer1 && nascimento <= cancer2) signo = "Câncer"; else if (nascimento >= leao1 && nascimento <= leao2) signo = "Leão"; else if (nascimento >= virgem1 && nascimento <= virgem2) signo = "Virgem"; else if (nascimento >= libra1 && nascimento <= libra2) signo = "Libra"; else if (nascimento >= escorpiao1 && nascimento <= escorpiao2) signo = "Escorpião"; else if (nascimento >= sagitario1 && nascimento <= sagitario2) signo = "Sagitário"; else signo = "Capricórnio"; return signo; } public List<string> Signo (List<DateTime> datas) { List<string> signos = new List<string>(); for(int i = 0; i < datas.Count; i++) { signos.Add(QualSigno(datas[i])); } return signos; } public List<Pessoa> FiltrarMaiores18 (List<Pessoa> pessoas) { List<Pessoa> maiores = new List<Pessoa>(); for(int i = 0; i < pessoas.Count; i++) { if(pessoas[i].Nascimento >= DateTime.Now.AddYears(-18)) { maiores.Add(pessoas[i]); } } return maiores; } public bool TodosMaiores18 (List<Pessoa> pessoas) { bool d = true; for(int i = 0; i < pessoas.Count; i++) { if(pessoas[i].Nascimento < DateTime.Now.AddYears(-18)) { d = false; } } return d; } } Pessoa a = new Pessoa(); a.Nascimento = new DateTime(2004,08,26); a.Nome = "Mariana Souza do Carmo"; Pessoa b = new Pessoa(); b.Nascimento = new DateTime(2004,06,16); b.Nome = "Levy Cauã da Silva Cabral"; Pessoa c = new Pessoa(); c.Nascimento = new DateTime(2004,09,10); c.Nome = "Matheus Rafael Rocha"; Pessoa d = new Pessoa(); d.Nascimento = new DateTime(1999,04,04); d.Nome = "Liedson Ferreira Junior"; List<Pessoa> e = new List<Pessoa>(); e.Add(a); e.Add(b); e.Add(c); e.Add(d); DateTime f = new DateTime(2000,09,08); DateTime g = new DateTime(2009,07,30); DateTime h = new DateTime(2004,08,26); DateTime i = new DateTime(2020,04,20); DateTime j = new DateTime(2021,12,31); List<DateTime> k = new List<DateTime>(); k.Add(f); k.Add(g); k.Add(h); k.Add(i); k.Add(j); TreinoFocadoB l = new TreinoFocadoB(); List<DateTime> m = new List<DateTime>(); m = l.GerarSequencia1(3); List<DateTime> n = new List<DateTime>(); n = l.GerarSequencia2(5,f); List<DateTime> o = new List<DateTime>(); o = l.GerarSequenciaNumerosPares(3,f); List<string> p = new List<string>(); p = l.Signo(k); List<Pessoa> q = new List<Pessoa>(); q = l.FiltrarMaiores18(e); bool r = l.TodosMaiores18 (q); Console.WriteLine(string.Join(" - ", m)); Console.WriteLine(string.Join(" - ", n)); Console.WriteLine(string.Join(" - ", o)); Console.WriteLine(string.Join(" - ", p)); Console.WriteLine(string.Join(" - ", q)); Console.WriteLine(r); // 29/06/2021 00:34:18 - 30/06/2021 00:34:18 - 01/07/2021 00:34:18 // 08/09/2000 00:00:00 - 09/09/2000 00:00:00 - 10/09/2000 00:00:00 - 11/09/2000 00:00:00 - 12/09/2000 00:00:00 //08/09/2000 00:00:00 - 10/09/2000 00:00:00 - 12/09/2000 00:00:00 //Virgem - Leão - Virgem - Áries - Capricórnio //Submission#0+Pessoa - Submission#0+Pessoa - Submission#0+Pessoa //True ``` ## TREINO FOCADO C ```csharp= using System; using System.Collections.Generic; public class Pessoa { public string Nome { get; set; } public DateTime Nascimento { get; set; } public string Cidade { get; set; } } public class TreinoFocadoC { public string SepararLetras (string frase) { string separado = string.Empty; for(int i = 0; i < frase.Length; i++) { separado += frase[i] + "-"; } return separado; } public string Inverter (string frase) { string invertido = string.Empty; for(int i = 0; i < frase.Length; i++) { invertido = frase[i] + invertido; } return invertido; } public bool TodasVogais (string frase) { bool a = true; string b = frase.ToLower(); for(int i = 0; i < frase.Length; i++) { if(b[i] != 'a' && b[i] != 'e' && b[i] != 'i' && b[i] != 'o' && b[i] != 'u') { a = false; } } return a; } private string UltimoNome (string nomeCompleto) { return nomeCompleto.Substring(nomeCompleto.LastIndexOf(' '), nomeCompleto.Length - nomeCompleto.LastIndexOf(' ')); } public List<string> UltimosNomes (List<string> nomeCompleto) { List<string> ultimo = new List<string>(); for(int i = 0; i <nomeCompleto.Count; i++) { ultimo.Add(UltimoNome(nomeCompleto[i])); } return ultimo; } public bool ApenasCoresPrimarias(List<string> cores) { bool d = true; string a = string.Empty; for (int i = 0; i < cores.Count; i++) { a = cores[i].ToLower(); if (a != "vermelho" && a != "azul" && a != "amarelo") { d = false; } } return d; } /* public bool SenhaForte (string senha) { List<char> numeros = new List<char>(); numeros.Add('1'); numeros.Add('2'); numeros.Add('3'); numeros.Add('4'); numeros.Add('5'); numeros.Add('6'); numeros.Add('7'); numeros.Add('8'); numeros.Add('9'); numeros.Add('1'); numeros.Add('0'); List<char> especiais = new List<char>(); especiais.Add('!'); especiais.Add('@'); especiais.Add('#'); especiais.Add('$'); especiais.Add('%'); especiais.Add('&'); especiais.Add('*'); bool forte = true; string a = string.Empty; for(int i = 0; i < senha.Length; i++) { if(senha[i] < 8 && senha[i] != especiais[*] && senha[i] != numeros [*] ); } return forte; } */ } Pessoa a = new Pessoa(); a.Cidade = "São Paulo"; a.Nascimento = new DateTime(2004,08,26); a.Nome = "Mariana Souza do Carmo"; List<string> b = new List<string>(); b.Add("Mariana Souza do Carmo"); b.Add("Levy Cauã da Silva Cabral"); b.Add("Vinicius Reimberg Bessa"); b.Add("Laura Faustino da Silva"); b.Add("Aysha Kauenya Fernandes Sampaio"); List<string> c = new List<string>(); c.Add("Amarelo"); c.Add("Azul"); c.Add("Vermelho"); TreinoFocadoC d = new TreinoFocadoC (); bool e = d.ApenasCoresPrimarias(c); string f = d.Inverter("HOHOHO! É NATAL!"); string g = d.SepararLetras("Bom dia!!"); bool h = d.TodasVogais("AEIOU"); List<string> i = new List<string>(); i = d.UltimosNomes(b); Console.WriteLine(e); Console.WriteLine(f); Console.WriteLine(g); Console.WriteLine(h); Console.WriteLine(string.Join(" - ", i)); //True //!LATAN É !OHOHOH //B-o-m- -d-i-a-!-!- //True // Carmo - Cabral - Bessa - Silva - Sampaio ```
{"metaMigratedAt":"2023-06-16T04:29:56.443Z","metaMigratedFrom":"Content","title":"ligas","breaks":true,"contributors":"[{\"id\":\"b186730d-b9e4-4a77-8f97-f67305b05247\",\"add\":14478,\"del\":0}]"}
Expand menu