Essays.club - TCC, Modelos de monografias, Trabalhos de universidades, Ensaios, Bibliografias
Pesquisar

Implementação de algorítmo imperativo(.net) tentando imitar um lógico(prolog)

Por:   •  29/5/2018  •  4.989 Palavras (20 Páginas)  •  253 Visualizações

Página 1 de 20

...

20);

MessageBox.Show(textoHomoIdade);

var textoHomo = Combinacoes("Homo");

MessageBox.Show(textoHomo);

var textoHetero = Combinacoes("Hetero");

MessageBox.Show(textoHetero);

var comb = Combinacoes("Homo", maria);

MessageBox.Show(comb);

}

private static void AddPes(List<Pessoa> lista)

{

foreach (var pessoa in lista)

{

if (pessoa.GetType() == typeof(Homem))

{

listaHomens.Add((Homem)pessoa);

}

if (pessoa.GetType() == typeof(Mulher))

{

listaMulheres.Add((Mulher)pessoa);

}

}

}

private static bool Casal(string type, Pessoa pes1, Pessoa pes2)

{

if (pes1.Equals(pes2))

{

return false;

}

if (type.Equals("Hetero"))

{

if (pes1.GetType() == typeof(Homem) && pes2.GetType() == typeof(Mulher))

{

return true;

}

if (pes1.GetType() == typeof(Mulher) && pes2.GetType() == typeof(Homem))

{

return true;

}

}

if (type.Equals("Homo"))

{

if (pes1.GetType() == typeof(Homem) && pes2.GetType() == typeof(Homem))

{

return true;

}

if (pes1.GetType() == typeof(Mulher) && pes2.GetType() == typeof(Mulher))

{

return true;

}

}

return false;

}

private static string Combinacoes(string type, Pessoa pes1)

{

if (type.Equals("Homo"))

{

if (pes1.GetType() == typeof(Homem))

{

string texto = "";

foreach (var txt in listaHomens)

{

if (txt.Nome != pes1.Nome)

{

texto += pes1.Nome + " => " + txt.Nome + "\n";

}

}

return texto;

}

if (pes1.GetType() == typeof(Mulher))

{

string texto = "";

foreach (var txt in listaMulheres)

{

if (txt.Nome != pes1.Nome)

{

texto += pes1.Nome + " => " + txt.Nome + "\n";

}

}

return texto;

}

}

if (type.Equals("Hetero"))

{

if (pes1.GetType() == typeof(Homem))

{

string texto = "";

foreach (var txt in listaMulheres)

{

texto += pes1.Nome + " => " + txt.Nome + "\n";

}

return texto;

}

if (pes1.GetType() == typeof(Mulher))

{

...

Baixar como  txt (10.7 Kb)   pdf (50 Kb)   docx (14.8 Kb)  
Continuar por mais 19 páginas »
Disponível apenas no Essays.club