public void ExemploRedisConteudoObjeto() { var valorObjeto = _cache.GetString("ValorObjeto"); Complexo objComplexo = null; if (valorObjeto == null) { objComplexo = new Complexo() { ValorString = "Pink Floyd", ValorInteiro = 1965, ValorDecimal = 250000000.00M }; valorObjeto = JsonConvert.SerializeObject(objComplexo); AdicionarValorCache("ValorObjeto", valorObjeto); } else { objComplexo = JsonConvert.DeserializeObject <Complexo>(valorObjeto); } ViewBag.ValorComplexo = objComplexo; }
/// <summary> /// Conceito de Design Patterns estudado: Template Method /// </summary> public static void ExecutaGeracaoRelatorios() { List <ContaBancaria> contas = new List <ContaBancaria>(); ContaBancaria conta1 = new ContaBancaria("Olivia", DateTime.Now); conta1.Deposita(1000000); contas.Add(conta1); ContaBancaria conta2 = new ContaBancaria("Gertrudes", DateTime.Now); conta2.Deposita(1000); contas.Add(conta2); Console.WriteLine(""); var relatorioSimples = new Simples(); var relatorioComplexo = new Complexo(); Console.WriteLine("****** RELATÓRIO SIMPLES ******"); GeradorDeRelatorios gerador = new GeradorDeRelatorios(); gerador.GeraRelatorios(contas, relatorioSimples); Console.WriteLine("\n"); Console.WriteLine("****** RELATÓRIO COMPLEXO ******"); gerador.GeraRelatorios(contas, relatorioComplexo); }
///<summary>Função que soma dois objetos complexos</summary> ///<param name="num1">recebe o valor do primeiro numero(objeto) complexo</param> ///<param name="num2">recebe o valor do segundo numero(objeto) complexo</param> static public void Somar(Complexo num1, Complexo num2) { double resul_real = num1._real + num2._real; // calcula a parte real resultante double resul_imag = num1._imag + num2._imag; //calcula a parte imaginaria resultante double resul_angulo = (Math.Atan(resul_imag / resul_real)) * 57.29; // calcula o angulo e converte de radianos para graus if (resul_real < 0) { resul_angulo = 180 + resul_angulo; // ajusta o quadrante } double resul_modulo = Math.Sqrt(Math.Pow(resul_real, 2) + Math.Pow(resul_imag, 2)); // calcula o modulo usando regra de pitagoras Console.WriteLine("Numero Somado:\n" + "Retangular: " + resul_real + " +(" + resul_imag + "i)\n" + "Polar(Graus): " + resul_modulo + " <" + resul_angulo + " °\n"); }
void OnRenderObject() { // set the current material lineMaterial.SetPass(0); GL.Begin(GL.QUADS); if (showMain) { float width = lineWidth / 100f; float tickX = tickSizeX / 100f; float tickY = tickSizeY / 100f; float startX = -gridSizeX / 2f; float startY = -gridSizeY / 2f; // X axis GL.Color(xColor); GL.Vertex3(startX - width / 2f, posY, 0); GL.Vertex3(startX - width / 2f, posY + width, 0); GL.Vertex3(startX + gridSizeX + width / 2f, posY + width, 0); GL.Vertex3(startX + gridSizeX + width / 2f, posY, 0); // Y Axis GL.Color(yColor); GL.Vertex3(posX, startY - width / 2f, 0); GL.Vertex3(posX + width, startY - width / 2f, 0); GL.Vertex3(posX + width, startY + gridSizeY + width / 2f, 0); GL.Vertex3(posX, startY + gridSizeY + width / 2f, 0); // X axis sublines GL.Color(xColor); float dist = ((posX + gridSizeX / 2f) % largeStep); if (dist < 0) { dist += largeStep; } for (float k = startX + dist; k <= startX + gridSizeX; k += largeStep) { if (Mathf.Abs(k - posX) > 0.1f) { GL.Vertex3(k - width / 2f, posY - tickX, 0); GL.Vertex3(k + width / 2f, posY - tickX, 0); GL.Vertex3(k + width / 2f, posY + tickX + width, 0); GL.Vertex3(k - width / 2f, posY + tickX + width, 0); } } // Y axis sublines GL.Color(yColor); dist = ((posY + gridSizeY / 2f) % largeStep); if (dist < 0) { dist += largeStep; } for (float j = startY + dist; j <= gridSizeY + startY; j += largeStep) { if (Mathf.Abs(j - posY) > 0.1f) { GL.Vertex3(posX - tickY, j - width / 2f, 0); GL.Vertex3(posX - tickY, j + width / 2f, 0); GL.Vertex3(posX + tickY + width, j + width / 2f, 0); GL.Vertex3(posX + tickY + width, j - width / 2f, 0); } } } GL.End(); if (Fasores != null) { GL.Begin(GL.LINES); foreach (FasorHandler f in Fasores) { GL.Color(f.cor); Complexo c = f.fasor.Retangular(0); GL.Vertex3(0, 0, 0); GL.Vertex3((float)c.Real, (float)c.Imaginario, 0f); } GL.End(); } }
///<summary>Função que gera um numero complexo, cria um numero complexo</summary> ///<param name="real">recebe o valor da parte real</param> ///<param name="imaginario">recebe o valor da parte imaginaria</param> ///<param name="">recebe o valor do modulo</param> ///<param name="">recebe o valor do angulo</param> ///<param name="">true para radianos, false para graus</param> ///<return>retorna um objeto da classe complexo</return> static public Complexo Complexo(double real = 0, double imaginario = 0, double modulo = 0, double angulo = 0, bool radiano = false) { Complexo numero_complexo = new Complexo(real, imaginario, modulo, angulo, radiano); return(numero_complexo); }