Commit e73bb7bf authored by suleman.hussain's avatar suleman.hussain

almost done

parent c63c9b9d
...@@ -14,6 +14,7 @@ void AddPokemonToList(struct Pokedex *pokemon, char name[16], char type[12], cha ...@@ -14,6 +14,7 @@ void AddPokemonToList(struct Pokedex *pokemon, char name[16], char type[12], cha
printf("Your Pokemon has successfully been added to the Pokedex!\n"); printf("Your Pokemon has successfully been added to the Pokedex!\n");
} }
} }
void AddPlayerToList(struct Pokedex *player, char name[16]) void AddPlayerToList(struct Pokedex *player, char name[16])
{ {
struct PlayerNode *current = (struct PlayerNode *)player->player_head; struct PlayerNode *current = (struct PlayerNode *)player->player_head;
...@@ -78,6 +79,7 @@ void DisplayPokemonDetails(struct Pokedex *pokedex, char name[12]){ ...@@ -78,6 +79,7 @@ void DisplayPokemonDetails(struct Pokedex *pokedex, char name[12]){
} }
void DisplayPlayerDetails(struct Pokedex *pokedex, char name[12]){ void DisplayPlayerDetails(struct Pokedex *pokedex, char name[12]){
struct PlayerNode *current = (struct PlayerNode *) pokedex -> player_head; struct PlayerNode *current = (struct PlayerNode *) pokedex -> player_head;
while(current != NULL){ while(current != NULL){
...@@ -94,6 +96,7 @@ void DisplayPlayerDetails(struct Pokedex *pokedex, char name[12]){ ...@@ -94,6 +96,7 @@ void DisplayPlayerDetails(struct Pokedex *pokedex, char name[12]){
printf("Sorry! I don't seem to have any record of that person.\n"); printf("Sorry! I don't seem to have any record of that person.\n");
} }
} }
void ListPokemon(struct Pokedex *pokedex) void ListPokemon(struct Pokedex *pokedex)
...@@ -119,7 +122,6 @@ void ListPokemon(struct Pokedex *pokedex) ...@@ -119,7 +122,6 @@ void ListPokemon(struct Pokedex *pokedex)
} }
} }
void ListPlayers(struct Pokedex *pokedex){ void ListPlayers(struct Pokedex *pokedex){
struct PlayerNode *current = (struct PlayerNode*) pokedex -> player_head; struct PlayerNode *current = (struct PlayerNode*) pokedex -> player_head;
while (current != NULL){ while (current != NULL){
...@@ -129,4 +131,4 @@ void ListPlayers(struct Pokedex *pokedex){ ...@@ -129,4 +131,4 @@ void ListPlayers(struct Pokedex *pokedex){
printf("%s\n", current -> name); printf("%s\n", current -> name);
current = current -> next; current = current -> next;
} }
} }
\ No newline at end of file
struct Pokedex {
struct PlayerNode *player_head;
struct PokemonNode *pokemon_head;
};
struct PokemonNode{ struct PokemonNode{
char name[16]; char name[16];
char type[12]; char type[12];
...@@ -17,6 +12,11 @@ struct PlayerNode{ ...@@ -17,6 +12,11 @@ struct PlayerNode{
struct PlayerNode *next; struct PlayerNode *next;
}; };
struct Pokedex {
struct PlayerNode *player_head;
struct PokemonNode *pokemon_head;
};
struct PokemonNode* NewPokemonNode(char name[16], char type[12], char ability[12]){ struct PokemonNode* NewPokemonNode(char name[16], char type[12], char ability[12]){
struct PokemonNode *newNode = (struct PokemonNode *) malloc(sizeof(struct PokemonNode)); struct PokemonNode *newNode = (struct PokemonNode *) malloc(sizeof(struct PokemonNode));
strcpy(newNode -> name, name); strcpy(newNode -> name, name);
...@@ -26,7 +26,6 @@ struct PokemonNode* NewPokemonNode(char name[16], char type[12], char ability[12 ...@@ -26,7 +26,6 @@ struct PokemonNode* NewPokemonNode(char name[16], char type[12], char ability[12
return newNode; return newNode;
} }
struct PokemonNode* FindPokemon(struct Pokedex *pokedex, char name[16]){ struct PokemonNode* FindPokemon(struct Pokedex *pokedex, char name[16]){
struct PokemonNode *current = (struct PokemonNode *) pokedex -> pokemon_head; struct PokemonNode *current = (struct PokemonNode *) pokedex -> pokemon_head;
while(current != NULL){ while(current != NULL){
...@@ -39,7 +38,6 @@ struct PokemonNode* FindPokemon(struct Pokedex *pokedex, char name[16]){ ...@@ -39,7 +38,6 @@ struct PokemonNode* FindPokemon(struct Pokedex *pokedex, char name[16]){
return NULL; return NULL;
} }
struct PlayerNode* NewPlayerNode(char name[16], int pokemonCount){ struct PlayerNode* NewPlayerNode(char name[16], int pokemonCount){
struct PlayerNode *newNode = (struct PlayerNode *) malloc(sizeof(struct PlayerNode)); struct PlayerNode *newNode = (struct PlayerNode *) malloc(sizeof(struct PlayerNode));
strcpy(newNode -> name, name); strcpy(newNode -> name, name);
...@@ -58,4 +56,4 @@ struct PlayerNode* FindPlayer(struct Pokedex *pokedex, char name[16]){ ...@@ -58,4 +56,4 @@ struct PlayerNode* FindPlayer(struct Pokedex *pokedex, char name[16]){
} }
printf("Sorry, I cant seem to find that person.\n"); printf("Sorry, I cant seem to find that person.\n");
return NULL; return NULL;
} }
\ No newline at end of file
No preview for this file type
...@@ -6,14 +6,6 @@ ...@@ -6,14 +6,6 @@
#include "linklist.c" #include "linklist.c"
#include "functions.c" #include "functions.c"
int main(){ int main(){
struct Pokedex pokedex; struct Pokedex pokedex;
pokedex.pokemon_head = NULL; pokedex.pokemon_head = NULL;
...@@ -27,7 +19,7 @@ int main(){ ...@@ -27,7 +19,7 @@ int main(){
AddPokemonToPlayer(&pokedex,"jim","bob","human","cry"); AddPokemonToPlayer(&pokedex,"jim","bob","human","cry");
AddPokemonToPlayer(&pokedex,"jim","suleman","sad","sobbing"); AddPokemonToPlayer(&pokedex,"jim","suleman","sad","sobbing");
bool run = true; bool run = true;
while (run=true){ while (run=true){
......
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