Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Pokedex_01
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
paolo.tokam
Pokedex_01
Commits
69afff45
Commit
69afff45
authored
Jan 17, 2023
by
paolo.tokam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update pokemon Structure
parent
4124687a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
0 deletions
+95
-0
Pokemon Structure
Pokemon Structure
+95
-0
pokemon Structure
pokemon Structure
+0
-0
No files found.
Pokemon Structure
0 → 100644
View file @
69afff45
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
//struct store info of a Pokemon
struct PokemonNode {
char name[15];
char ability[15];
char type[15];
struct PokemonNode *next;
struct PokemonNode *prev;
};
//struct store info of Player
struct PlayerNode {
char name[15];
int PlayersNumber;
int PokemonCount;
struct PokemonCount *PlayerPokemon[100];
struct PlayerNode *next;
struct PlayerNode *prev;
};
//struct to store in the Pokedex
struct Pokedex {
struct PokemonNode *headPokemon;
struct PlayerNode *headPlayer;
};
//Make a Pokedex
struct Pokedex pokedex;
// inorder to make a new Pokemon node we need to apply a Function
struct PokemonNode *createPokemonNode(char name[], char ability[], char type[]){
struct PokemonNode * NWNode = (struct PokemonNode *)malloc(sizeof (struct PokemonNode));
strcpy(NWNode->name, name);
strcpy(NWNode->ability, ability);
NWNode->next = NULL;
NWNode->prev = NULL;
return NWNode;
}
// Inorder to add new pokemon into list we need to apply a Function
void addPokemonToList(struct PokemonNode *NWnode){
if (pokedex.headPokemon == NULL){
pokedex.headPokemon = NWnode;
} else {
struct PokemonNode *current = pokedex.headPokemon;
while (current->next != NULL) {
}
current-> next = NWnode;
NWnode->prev = current;
}
}
// Inorder to search for a pokemon using name we need to apply a Function
struct PokemonNode *searchPokemonByName(char name[]){
struct PokemonNode *current = pokedex.headPokemon;
while (current != NULL){
if (strcmp(current->name, name)) == 0) {
return current;
}
current = current->next;
}
return NULL;
}
// Inorder to create a new Player node we need to apply a Function
struct PlayerNode *createPokemonNode(char name[]) {
struct PlayerNode *NWnode = (struct PlayerNode *)malloc(sizeof(struct PlayerNode));
strcpy(NWnode->name, name);
NWnode->PokemonCount = 0;
NWnode->next = NULL;
NWnode->prev = NULL;
return NWnode;
}
//Inorder to add a new Player to the List we need to apply a Function
void addPlayerToList(struct PlayerNode *NWnode){
if (pokedex.headPlayer == NULL) {
pokedex.headPlayer == NWnode;
} else {
struct PlayerNode *current = pokedex.headPlayer;
while (current-> next != NULL ) {
current = current-> next;
}
current->next = NWnode;
NWnode->prev = current;
}
}
pokemon Structure
deleted
100644 → 0
View file @
4124687a
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment