Commit 6aab8598 authored by bryan.quispe's avatar bryan.quispe

Add new file

parents
#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
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