-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
140 lines (128 loc) · 6.16 KB
/
Program.cs
File metadata and controls
140 lines (128 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using PokedexCharp.Models;
using PokedexCharp.Util;
PokedexClient client = new();
ParserJson parser = new();
Person person = new Person();
Saudacoes();
Menu();
#region
void Saudacoes()
{
char number = ' ';
Console.WriteLine(" ,'\\\r\n _.----. ____ ,' _\\ ___ ___ ____\r\n_,-' `. | | /`. \\,-' | \\ / | | \\ |`.\r\n\\ __ \\ '-. | / `. ___ | \\/ | '-. \\ | |\r\n \\. \\ \\ | __ | |/ ,','_ `. | | __ | \\| |\r\n \\ \\/ /,' _`.| ,' / / / / | ,' _`.| | |\r\n \\ ,-'/ / \\ ,' | \\/ / ,`.| / / \\ | |\r\n \\ \\ | \\_/ | `-. \\ `' /| | || \\_/ | |\\ |\r\n \\ \\ \\ / `-.`.___,-' | |\\ /| \\ / | | |\r\n \\ \\ `.__,'| |`-._ `| |__| \\/ | `.__,'| | | |\r\n \\_.-' |__| `-._ | '-.| '-.| | |\r\n `' '-._|");
Console.WriteLine("===================================================================");
Console.WriteLine("|| ||");
Console.WriteLine("|| Seja bem vindo ao POKEDEX! ||");
Console.WriteLine("|| ||");
Console.WriteLine("===================================================================");
bool notSure = true;
while (notSure)
{
Console.WriteLine("===================================================================");
Console.WriteLine("|| Qual o seu nome? ||");
Console.WriteLine("===================================================================");
string nome = Console.ReadLine();
Console.WriteLine("===================================================================");
Console.WriteLine($"|| Certeza que o seu nome é {nome}? ||");
Console.WriteLine("===================================================================");
Console.WriteLine("|| (1) Sim! ||");
Console.WriteLine("|| (2) Não! ||");
Console.WriteLine("===================================================================");
try
{
number = Console.ReadLine()[0];
}
catch
{
Console.WriteLine("Opção Inválida");
}
if (number.Equals('1'))
{
notSure = false;
person.Name = nome;
}
}
}
void Menu()
{
char option = ' ';
while (!option.Equals('3'))
{
Console.WriteLine("===================================================================");
Console.WriteLine($"|| Então {person.Name}, o que deseja fazer? ||");
Console.WriteLine("===================================================================");
Console.WriteLine("|| ||");
Console.WriteLine("|| (1) Adotar um mascote ||");
Console.WriteLine("|| (2) Ver mascotes adotados ||");
Console.WriteLine("|| (3) Sair do jogo ||");
Console.WriteLine("|| ||");
Console.WriteLine("===================================================================");
try
{
option = Console.ReadLine()[0];
}
catch
{
Console.WriteLine("Opção Inválida");
}
finally
{
ExecuteOption(option);
}
}
}
void ExecuteOption(char option)
{
switch (option)
{
case '1':
Console.WriteLine("==================== Adotando um Pokemon ==========================");
Console.WriteLine("|| Escolha a sua espécie ||");
Console.WriteLine("===================================================================");
ListPokemons();
String chose = Console.ReadLine();
ShowAdoptionActions();
ListPokemonByNameOrId(chose);
break;
case '6':
Console.WriteLine("Saindo do programa! Tchau!");
break;
default:
Console.WriteLine("===================================================================");
Console.WriteLine("|| Ok! Adeus! ||");
Console.WriteLine("===================================================================");
break;
}
}
void ShowAdoptionActions()
{
Console.WriteLine("==================== Sobre este Pokemon ==========================");
Console.WriteLine("|| (1) Saber mais sobre o ||");
Console.WriteLine("===================================================================");
}
void ListPokemons()
{
string jsonGetAllPokemons = client.GetRequest();
List<Pokemon> pokemonList = parser.ParseAllPokemons(jsonGetAllPokemons);
foreach (Pokemon pokemon in pokemonList)
{
Console.WriteLine($"({pokemon.Id}) {pokemon.Name}");
}
}
void ListPokemonByNameOrId(String nameOrID)
{
string jsonGetPokemon = client.GetRequestByNameOrId(nameOrID);
if(jsonGetPokemon != null)
{
Pokemon pokemon = parser.ParsePokemon(jsonGetPokemon);
pokemon.ToString();
} else
{
Console.WriteLine("===================================================================");
Console.WriteLine("|| Este Pokemon não foi encontrado. ||");
Console.WriteLine("===================================================================");
}
}
#endregion
// var jsonGetAllPokemons = client.GetRequestByName("charmeleon");
// cw(jsonGetAllPokemons);