Commit 0dbf6af5 authored by elijah vasquez's avatar elijah vasquez 🦍

commitidk

parent 2d99774c
{ {
"files.associations": { "files.associations": {
"functions.h": "c", "functions.h": "c",
"typeinfo": "c" "typeinfo": "c",
"stdbool.h": "c"
} }
} }
\ No newline at end of file
File added
// Pokemon List // Pokemon List
typedef struct PokemonNode typedef struct PokemonNode
{ {
char name[20]; char name[12];
char type[20]; char type[20];
char ability[30]; char ability[25];
struct PokemonNode *next; struct PokemonNode *next;
} PokemonNode; } PokemonNode;
// Player List // Player List
typedef struct PlayerNode typedef struct PlayerNode
{ {
char name[50]; char name[25];
int totalPokemon; int totalPokemon;
PokemonNode *PokemonArray[20]; PokemonNode* PokemonArray[20];
struct PlayerNode *next; struct PlayerNode *next;
} PlayerNode; } PlayerNode;
...@@ -26,21 +25,21 @@ typedef struct Pokedex ...@@ -26,21 +25,21 @@ typedef struct Pokedex
// Pokemon List functions // Pokemon List functions
PokemonNode* NewPokemonNode(char name[20], char type[20], char ability[30]); PokemonNode* NewPokemonNode(Pokedex* pokedex, char name[25], char type[25], char ability[30]);
void AddPokemonToList(Pokedex **pokedex, char name[20], char type[20], char ability[30]); void AddPokemonToList(Pokedex** pokedex, char name[25], char type[25], char ability[30]);
PokemonNode* FindPokemon(Pokedex pokedex, char name[20]); PokemonNode* FindPokemon(Pokedex* pokedex, char name[25]);
// Player List functions // Player List functions
PlayerNode* NewPlayerNode(char name[50]); PlayerNode* NewPlayerNode(char name[50]); // Create new node, return pointer to node
void AddPlayerToList(Pokedex *pokedex, char name[50]); void AddPlayerToList(Pokedex* pokedex, char name[50]); // Check if name already exists in Player list.
PlayerNode* FindPlayer(Pokedex pokedex, char name[50]); PlayerNode* FindPlayer(Pokedex* pokedex, char name[50]); // Searches Player list for name.
// Additional functions // Additional functions
void AddPokemonToPlayer(Pokedex pokedex, char playerName[50], char pokemonName[20]); void AddPokemonToPlayer(Pokedex* pokedex, char playerName[50], char pokemonName[20]); // Adds Pokemon to player's Pokemon list
void DisplayPokemonDetails(Pokedex *pokedex, char name[20]); void DisplayPokemonDetails(Pokedex* pokedex, char name[20]); // Output details of pokemon
void DisplayPlayerDetails(Pokedex *pokedex, char name[50]); void DisplayPlayerDetails(Pokedex* pokedex, char name[20]); // output details of players, incl. list of names of pokemon owned
void ListPokemon(Pokedex* pokedex); void ListPokemon(Pokedex* pokedex); //output list of names of all POKEMON in pokedex
void ListPlayers(Pokedex* pokedex); void ListPlayers(Pokedex* pokedex); //output list of names of all PLAYERS in pokedex
void AddToPokemonArray(Pokedex *pokedex, char namePoke[20], char namePlayer[50]); void AddToPokemonArray(Pokedex* pokedex, char namePoke[20], char namePlayer[50]);
...@@ -6,17 +6,35 @@ ...@@ -6,17 +6,35 @@
int main(void) int main(void)
{ {
Pokedex *pokedexNode = NULL; Pokedex *pokedex = NULL;
pokedexNode = malloc(sizeof(struct PokemonNode)); pokedex = malloc(sizeof(pokedex));
pokedexNode -> pokemonNodehead = NULL; pokedex -> pokemonNodehead = NULL;
pokedexNode -> PlayerNodehead = NULL; pokedex -> PlayerNodehead = NULL;
// Calling functs. to create list of Pokemon
// Calling functs. to create list of players // Adding Pokemon to list
AddPokemonToList(&pokedex, "blastoise", "water", "torrent");
AddPokemonToList(&pokedex, "dragapult", "dragon", "infiltrator");
AddPokemonToList(&pokedex, "volcarona", "fire", "flame body");
AddPokemonToList(&pokedex, "regieleki", "electric", "transistor");
// Adding player to player list
AddPlayerToList(&pokedex, "armin");
AddPlayerToList(&pokedex, "chase");
AddPlayerToList(&pokedex, "ziggy");
// Adding pokemon to player
AddPokemonToPlayer(pokedex, "armin", "blastoise");
AddPokemonToPlayer(pokedex, "armin", "dragapult");
AddPokemonToPlayer(pokedex, "chase", "dragapult");
AddPokemonToPlayer(pokedex, "chase", "regieleki");
AddPokemonToPlayer(pokedex, "chase", "volcarona");
AddPokemonToPlayer(pokedex, "ziggy", "regieleki");
ListPokemon(pokedex);
ListPlayers(pokedex);
}
return 0;
}
File deleted
har name[20]);
void DisplayPlayerDetails(Pokedex *pokedex, ch
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment