Commit d34bd1e5 authored by Michelangelo's avatar Michelangelo

add README

parent 2627da2d
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Define a struct to store information about a Pokemon
struct PokemonNode {
char name[20];
char ability[20];
struct PokemonNode *next;
struct PokemonNode *prev;
};
// Define a struct to store information about a player
struct PlayerNode {
char name[20];
int pokemonCount;
struct PokemonNode *ownedPokemon[100];
struct PlayerNode *next;
struct PlayerNode *prev;
};
// Define a struct to store the Pokedex
struct Pokedex {
struct PokemonNode *headPokemon;
struct PlayerNode *headPlayer;
};
// Create a Pokedex
struct Pokedex pokedex;
// Function to create a new Pokemon node
struct PokemonNode *createPokemonNode(char name[], char ability[]) {
struct PokemonNode *newNode = (struct PokemonNode *)malloc(sizeof(struct PokemonNode));
strcpy(newNode->name, name);
strcpy(newNode->ability, ability);
newNode->next = NULL;
newNode->prev = NULL;
return newNode;
}
// Function to add a new Pokemon to the list
void addPokemonToList(struct PokemonNode *newNode) {
if (pokedex.headPokemon == NULL) {
pokedex.headPokemon = newNode;
} else {
struct PokemonNode *current = pokedex.headPokemon;
while (current->next != NULL) {
current = current->next;
}
current->next = newNode;
newNode->prev = current;
}
}
// Function to search for a Pokemon by name
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;
}
// Function to create a new Player node
struct PlayerNode *createPlayerNode(char name[]) {
struct PlayerNode *newNode = (struct PlayerNode *)malloc(sizeof(struct PlayerNode));
strcpy(newNode->name, name);
newNode->pokemonCount = 0;
newNode->next = NULL;
newNode->prev = NULL;
return newNode;
}
// Function to add a new Player to the list
void addPlayerToList(struct PlayerNode *newNode) {
if (pokedex.headPlayer == NULL) {
pokedex.headPlayer = newNode;
} else {
struct PlayerNode *current = pokedex.headPlayer;
while (current->next != NULL) {
current = current->next;
}
current->next = newNode;
newNode->prev = current;
}
}
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