Commit d1531612 authored by luke.scott's avatar luke.scott

Add new file

parents
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//Player and Pokemon Struct store varibales
typedef struct Pokemon
{
char name[20];
char type[20];
char move[20];
struct Pokemon *next;
} Pokemon;
typedef struct Player
{
char playerName[20];
char pokemon[20];
struct Player *next;
} Player;
typedef struct Pokedex
{
//Allow data to be entered into each 'poke' / 'player'
Pokemon *Pokehead;
Pokemon *SecondPokemon;
Pokemon *ThirdPokemon;
Pokemon *ForthPokemon;
Pokemon *Fifthpokemon;
Player *Playerhead;
Player *SecondPlayer;
Player *Thirdplayer;
Player *Fourthplayer;
Player *Fifthplayer;
} Pokedex ;
//new pokemon node to store name type and moves
struct Pokemon *newPokemonNode(char name[20], char type[20], char move[20])
{
Pokemon *Temp = (Pokemon*) malloc(sizeof(Pokemon));
if(Temp == NULL)
{
exit(0);
}
strcpy(Temp->name,name);
strcpy(Temp->type,type);
strcpy(Temp->move,move);
Temp->next=NULL;
return Temp;
}
//new player to store player name and favourite pokemon
struct Player *newPlayerNode(char playerName[20], char pokemon[20])
{
Player *Temp = (Player*) malloc(sizeof(Player));
if(Temp == NULL)
{
exit(0);
}
strcpy(Temp->playerName,playerName);
strcpy(Temp->pokemon,pokemon);
Temp->next=NULL;
return Temp;
}
void PrintPlayer(Player* aPlayer)
{
printf("User Name: %s\n", aPlayer->playerName);
printf("Favourite Pokemon: %s\n", aPlayer->pokemon);
}
void PrintPokemon(Pokemon* aPokemon)
{
printf("Pokemon: %s\n", aPokemon->name);
printf("Type: %s\n", aPokemon->type);
printf("Move: %s\n", aPokemon->move);
}
//main
int main ()
{
Pokedex myPokedex;
Pokedex *mypokepoint = &myPokedex;
mypokepoint->Playerhead = NULL;
mypokepoint->SecondPlayer = NULL;
mypokepoint->Thirdplayer = NULL;
mypokepoint->Pokehead = NULL;
mypokepoint->SecondPokemon = NULL;
mypokepoint->ThirdPokemon = NULL;
//pokedexpointer to be used to print data
mypokepoint->Playerhead = newPlayerNode("Ash","Pikachu");
mypokepoint->SecondPlayer = newPlayerNode("Mitch","Charizard");
mypokepoint->Thirdplayer = newPlayerNode("Luke","Bulbasuar");
mypokepoint->Fourthplayer = newPlayerNode("Dave", "Squirtle");
mypokepoint->Fifthplayer = newPlayerNode("Sapphire", "Jigglepuff");
//pokedex pointers
mypokepoint->Pokehead = newPokemonNode("Pikachu","Yellowthing","Lighting");
mypokepoint->SecondPokemon = newPokemonNode("Weedle","Earth","Earthquake");
mypokepoint->ThirdPokemon = newPokemonNode("Charizard","Fire","Flamethrower");
mypokepoint->Fourthplayer = newPokemonNode("Squirtle","Water","Water-Gun");
//Print users
printf("\n");
printf("Users in the Pokedex = 3");
printf("\n");
printf("\n");
PrintPlayer(mypokepoint->Playerhead);
printf("\n");
PrintPlayer(mypokepoint->SecondPlayer);
printf("\n");
PrintPlayer(mypokepoint->Thirdplayer);
printf("\n");
//Print pokemon
printf("\n");
printf("Pokemon found in the pokedex = 3");
printf("\n");
printf("\n");
PrintPokemon(mypokepoint->Pokehead);
printf("\n");
PrintPokemon(mypokepoint->SecondPokemon);
printf("\n");
PrintPokemon(mypokepoint->ThirdPokemon);
}
void AddPokemonToList(name,type,move)
{
}
//Display all player info
void DisplayPlayerDetails()
{
return 0;
}
//DIsplay pokemon info
void DisplayPokemonDetails()
{
return 0;
}
\ 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