Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Pokedex
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
bryan.quispe
Pokedex
Commits
6aab8598
Commit
6aab8598
authored
Jan 17, 2023
by
bryan.quispe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
148 additions
and
0 deletions
+148
-0
Pokedex
Pokedex
+148
-0
No files found.
Pokedex
0 → 100644
View file @
6aab8598
#include <stdio.h>
#include <stdlib.h>
typedef struct Player {
int id;
char *name;
int pokemon_count;
struct Player *next;
} Player;
typedef struct Pokemon {
int id;
char *name;
struct Pokemon *next;
} Pokemon;
typedef struct Pokedex {
Player *head_player;
Pokemon *head_pokemon;
} Pokedex;
Pokedex pokedex;
// Create a new player node and add it to the linked list
void add_player(int id, char *name) {
Player *new_player = malloc(sizeof(Player));
new_player->id = id;
new_player->name = name;
new_player->pokemon_count = 0;
new_player->next = pokedex.head_player;
pokedex.head_player = new_player;
}
// Create a new pokemon node and add it to the linked list
void add_pokemon( )
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct PokemonNode {
char *name;
char *type;
char *ability;
struct PokemonNode *next;
} PokemonNode;
// Create a new Pokemon node
PokemonNode *create_node(char *name, char *type, char *ability) {
PokemonNode *node = malloc(sizeof(PokemonNode));
node->name = name;
node->type = type;
node->ability = ability;
node->next = NULL;
return node;
}
// Add a node to the list
void add_node(PokemonNode **head, PokemonNode *node) {
node->next = *head;
*head = node;
}
// Find a specific node in the list (by Pokemon name)
PokemonNode *find_node(PokemonNode *head, char *name)
PokemonNode *curr = head;
while (curr) {}
if (strcmp(curr->name
)
)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct PokemonNode {
char *name;
char *type;
char *ability;
struct PokemonNode *next;
} PokemonNode;
typedef struct PlayerNode {
char *name;
int pokemon_count;
PokemonNode **owned_pokemon;
struct PlayerNode *next;
} PlayerNode;
// Create a new Player node
PlayerNode *create_node(char *name) {
PlayerNode *node = malloc(sizeof(PlayerNode));
node->name = name;
node->pokemon_count = 0;
node->owned_pokemon = malloc(sizeof(PokemonNode*));
node->next = NULL;
return node;
}
// Add a node to the list
void add_node(PlayerNode **head, PlayerNode *node) {
node->next = *head;
*head = node;
}
// Find a specific node in the list (
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Player {
int id;
char *name;
int pokemon_count;
struct Player *next;
} Player;
typedef struct Pokemon {
int id;
char *name;
char *type;
char *ability;
struct Pokemon *next;
} Pokemon;
typedef struct Pokedex {
Player *head_player;
Pokemon *head_pokemon;
} Pokedex;
Pokedex pokedex;
// Display details of a Pokemon
void DisplayPokemonDetails(Pokedex pokedex, char *name) {
Pokemon *curr = pokedex.head_pokemon;
while (curr) {
if (strcmp(curr->name, name) == 0) {
printf("Name: %s\nType: %s\nAbility: %s\n", curr->name, curr->type, curr->ability);
break;
} } }
\ No newline at end of file
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