Commit e4ce6059 authored by elijah vasquez's avatar elijah vasquez 🦍

hellyeah

parent 8e533737
...@@ -27,21 +27,21 @@ typedef struct Pokedex // To house the header nodes to start single ...@@ -27,21 +27,21 @@ typedef struct Pokedex // To house the header nodes to start single
// Pokemon List // Pokemon List
PokemonNode* NewPokemonNode(char name[20], char type[20], char ability[30]); PokemonNode* NewPokemonNode(char name[20], char type[20], char ability[30]); // Create new pokemon
void AddPokemonToList(Pokedex* pokedex, char name[20], char type[20], char ability[30]); void AddPokemonToList(Pokedex* pokedex, char name[20], char type[20], char ability[30]); //Add pokemon to list
PokemonNode* FindPokemon(Pokedex* pokedex, char name[20]); PokemonNode* FindPokemon(Pokedex* pokedex, char name[20]); //Find pokemon within list
// Player List // Player List
PlayerNode* NewPlayerNode(char name[50]); // Create new node, return pointer to node PlayerNode* NewPlayerNode(char name[50]); // Create new node, return pointer to node
void AddPlayerToList(Pokedex* pokedex, char name[50]); // Check if name already exists in Player list. void AddPlayerToList(Pokedex* pokedex, char name[50]); // Check if name already exists in Player list.
PlayerNode* FindPlayer(Pokedex* pokedex, char name[50]); // Searches Player list for name. PlayerNode* FindPlayer(Pokedex* pokedex, char name[50]); // Searches Player list for name.
void AddPokemonToPlayer(Pokedex* player, Pokedex* pokemon, char playerName[50], char pokemonName[20]); // Adds Pokemon to player's Pokemon list void AddPokemonToPlayer(Pokedex* player, Pokedex* pokemon, char playerName[50], char pokemonName[20]); // Adds Pokemon to player's Pokemon list
// Additional // Additional
// Pokemon details // Pokemon details
void DisplayPokemonDetails(Pokedex* pokedex, char name[20]); // Output details of pokemon void DisplayPokemonDetails(Pokedex* pokedex, char name[20]); // Output details of pokemon
PokemonNode* ListPokemon(Pokedex* pokedex); //output list of names of all POKEMON in pokedex PokemonNode* ListPokemon(Pokedex* pokedex); //output list of names of all POKEMON in pokedex
// Pokemon players // Pokemon players
void DisplayPlayerDetails(Pokedex* pokedex, char name[50]); // output details of players, incl. list of names of pokemon owned void DisplayPlayerDetails(Pokedex* pokedex, char name[50]); // output details of players, incl. list of names of pokemon owned
PlayerNode * ListPlayers(Pokedex* pokedex); //output list of names of all PLAYERS in pokedex PlayerNode * ListPlayers(Pokedex* pokedex); //output list of names of all PLAYERS in pokedex
// Calling of functions and setting up nodes // Calling of functions
#include "functions.h" #include "functions.h"
int main(void) int main(void)
{ // Adding Pokemon nodes to list { // Adding Pokemon nodes to list
Pokedex* pokeHead = NewPokemonNode("blastoise", "water", "torrent"); //Creation of node to introduce head of single linked list Pokedex* pokeHead = NewPokemonNode("blastoise", "water", "torrent"); // Creation of new pokemon as node to introduce head of single linked list
AddPokemonToList(pokeHead, "dragapult", "dragon", "infiltrator"); AddPokemonToList(pokeHead, "dragapult", "dragon", "infiltrator");
AddPokemonToList(pokeHead, "volcarona", "fire", "flame body"); AddPokemonToList(pokeHead, "volcarona", "fire", "flame body");
AddPokemonToList(pokeHead, "regieleki", "electric", "transistor"); AddPokemonToList(pokeHead, "regieleki", "electric", "transistor");
// Adding player nodes to player list // Adding player nodes to player list
Pokedex* playerHead = NewPlayerNode("armin"); Pokedex* playerHead = NewPlayerNode("armin"); // Creation of new player as node to introduce head of player list
AddPlayerToList(playerHead, "chase"); AddPlayerToList(playerHead, "chase");
AddPlayerToList(playerHead, "ziggy"); AddPlayerToList(playerHead, "ziggy");
// Linking pokemon with players // Linking pokemon with players
AddPokemonToPlayer(pokeHead, playerHead, "armin", "blastoise"); AddPokemonToPlayer(pokeHead, playerHead, "armin", "blastoise"); // pointer variables from above used within parameter to assign pokemon to players
AddPokemonToPlayer(pokeHead, playerHead, "armin", "dragapult"); AddPokemonToPlayer(pokeHead, playerHead, "armin", "dragapult");
AddPokemonToPlayer(pokeHead, playerHead, "chase", "volcarona"); AddPokemonToPlayer(pokeHead, playerHead, "chase", "volcarona");
AddPokemonToPlayer(pokeHead, playerHead, "ziggy", "regieleki"); AddPokemonToPlayer(pokeHead, playerHead, "ziggy", "regieleki");
...@@ -25,6 +25,10 @@ int main(void) ...@@ -25,6 +25,10 @@ int main(void)
ListPlayers(playerHead); ListPlayers(playerHead);
// Display details of each player // Display details of each player
/*
This section can be regarded as a dissection of ListPokemon
and ListPlayers.
*/
DisplayPlayerDetails(playerHead, "armin"); DisplayPlayerDetails(playerHead, "armin");
DisplayPlayerDetails(playerHead, "chase"); DisplayPlayerDetails(playerHead, "chase");
DisplayPlayerDetails(playerHead, "ziggy"); DisplayPlayerDetails(playerHead, "ziggy");
......
No preview for this file type
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