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
sam.pople
Pokedex
Commits
4e382470
Commit
4e382470
authored
Feb 06, 2023
by
sam.pople
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
8a433112
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
18 deletions
+21
-18
mainpokedex.c
mainpokedex.c
+19
-16
mainpokedex.exe
mainpokedex.exe
+0
-0
pokedexstructs.h
pokedexstructs.h
+2
-2
No files found.
mainpokedex.c
View file @
4e382470
...
...
@@ -2,13 +2,13 @@
# include <stdlib.h>
# include <string.h>
# include "pokedexstructs.h"
//main file. Run from here.
//main file. Run from here.
Click Run Code on VSC to run.
//functions
void
ListPokemon
(
Pokedex
*
pokedexpointer
)
{
// This displays the list of pokemon.
//This assigns a node to be a head for the pokemon list
PokemonNode
*
current
=
pokedexpointer
->
pokemonhead
;
PokemonNode
*
current
=
pokedexpointer
->
pokemonhead
;
printf
(
"
\n
List of Pokemon:
\n
"
);
while
(
current
!=
NULL
)
{
//The current node is printed and then the next is assigned.
...
...
@@ -39,7 +39,6 @@ PokemonNode* NewPokemonNode(char pokename[20], char poketype[20], char pokeabili
strcpy
(
addnode
->
name
,
pokename
);
strcpy
(
addnode
->
type
,
poketype
);
strcpy
(
addnode
->
ability
,
pokeability
);
return
addnode
;
}
//This creates each Player node
...
...
@@ -54,9 +53,8 @@ PlayerNode *NewPlayerNode(char playername[20])
return
addnode
;
}
//This finds the Pokemon in the Pokemon list
PokemonNode
*
FindPokemon
(
PokemonNode
*
pokehead
,
char
pokename
[
20
])
PokemonNode
*
FindPokemon
(
PokemonNode
*
pokehead
,
char
pokename
[
20
])
{
PokemonNode
*
current
=
pokehead
;
while
(
current
!=
NULL
)
{
...
...
@@ -70,7 +68,7 @@ PokemonNode* FindPokemon(PokemonNode* pokehead, char pokename[20])
return
current
;
}
}
return
0
;
return
NULL
;
}
//This searches the list for the specific player
PlayerNode
*
FindPlayer
(
PlayerNode
*
playerhead
,
char
playername
[
20
])
...
...
@@ -92,13 +90,15 @@ PlayerNode* FindPlayer(PlayerNode* playerhead, char playername[20])
//This adds a new Pokemon to the Pokemon list
void
AddPokemonToList
(
Pokedex
*
pokedexpointer
,
char
pokename
[
20
],
char
poketype
[
20
],
char
pokeability
[
50
])
{
if
(
FindPokemon
(
pokedexpointer
->
pokemonhead
,
pokename
)
!=
0
)
//This checks if the Pokemon already exists
if
(
FindPokemon
(
pokedexpointer
->
pokemonhead
,
pokename
)
!=
NULL
)
{
printf
(
"Pokemon exists
\n
"
);
}
else
//This adds new node and adds the Pokemon to the list
{
PokemonNode
*
current
=
NewPokemonNode
(
pokename
,
poketype
,
pokeability
);
PokemonNode
*
current
=
NewPokemonNode
(
pokename
,
poketype
,
pokeability
);
current
->
nextpokemon
=
pokedexpointer
->
pokemonhead
;
pokedexpointer
->
pokemonhead
=
current
;
printf
(
"Pokemon %s added
\n
"
,
pokename
);
...
...
@@ -129,6 +129,7 @@ void AddPokemonToPlayer(Pokedex* pokedexpointer, char pokemon[20], char player[2
{
for
(
int
x
=
0
;
x
<=
PlayerPointer
->
numofpokemon
;
x
++
)
{
//This adds the Pokemon to the player if he isn't already there
if
(
PlayerPointer
->
PokemonArray
[
x
]
==
NULL
)
{
PlayerPointer
->
PokemonArray
[
x
]
=
PokemonPointer
;
...
...
@@ -136,6 +137,7 @@ void AddPokemonToPlayer(Pokedex* pokedexpointer, char pokemon[20], char player[2
printf
(
"
\n
The Pokemon %s is now with the player %s."
,
PokemonPointer
->
name
,
PlayerPointer
->
name
);
break
;
}
//This checks if the Pokemon already exists with the player
else
if
(
PlayerPointer
->
PokemonArray
[
x
]
==
PokemonPointer
)
{
printf
(
"
\n
%s is already with %s.
\n
"
,
PokemonPointer
->
name
,
PlayerPointer
->
name
);
...
...
@@ -192,7 +194,13 @@ int main(void)
pokedexvalues
.
playerhead
=
playerhead
;
pokedexvalues
.
pokemonhead
=
pokemonhead
;
//This function adds players to the pokedex
AddPlayerToList
(
pokedexvaluespointer
,
"Stephen"
);
AddPlayerToList
(
pokedexvaluespointer
,
"Sandra"
);
AddPlayerToList
(
pokedexvaluespointer
,
"Jack"
);
//This tests players that are already added
AddPlayerToList
(
pokedexvaluespointer
,
"Sandra"
);
//This adds Pokemon to the Pokedex list and sets their values
AddPokemonToList
(
pokedexvaluespointer
,
"Jigglypuff"
,
"Fairy"
,
"Cute Charm"
);
AddPokemonToList
(
pokedexvaluespointer
,
"Venusaur"
,
"Grass"
,
"Overgrow"
);
...
...
@@ -209,13 +217,7 @@ int main(void)
AddPokemonToList
(
pokedexvaluespointer
,
"Darkrai"
,
"Dark"
,
"Bad Dreams"
);
AddPokemonToList
(
pokedexvaluespointer
,
"Pikachu"
,
"Electric"
,
"Static"
);
//This tests a Pokemon that already exists
AddPokemonToList
(
pokedexvaluespointer
,
"Pikachu"
,
"Electric"
,
"Static"
);
//This function adds players to the pokedex
AddPlayerToList
(
pokedexvaluespointer
,
"Stephen"
);
AddPlayerToList
(
pokedexvaluespointer
,
"Sandra"
);
AddPlayerToList
(
pokedexvaluespointer
,
"Jack"
);
//This tests players that are already added
AddPlayerToList
(
pokedexvaluespointer
,
"Sandra"
);
AddPokemonToList
(
pokedexvaluespointer
,
"Pikachu"
,
"Electric"
,
"Static"
);
//This assigns the pokemon to players
AddPokemonToPlayer
(
pokedexvaluespointer
,
"Jigglypuff"
,
"Sandra"
);
AddPokemonToPlayer
(
pokedexvaluespointer
,
"Bidoof"
,
"Jack"
);
...
...
@@ -237,6 +239,7 @@ int main(void)
DisplayPokemonDetails
(
pokedexvaluespointer
,
"Darkrai"
);
DisplayPokemonDetails
(
pokedexvaluespointer
,
"Dialga"
);
DisplayPokemonDetails
(
pokedexvaluespointer
,
"Gengar"
);
DisplayPokemonDetails
(
pokedexvaluespointer
,
"Bidoof"
);
DisplayPokemonDetails
(
pokedexvaluespointer
,
"Palkia"
);
//This displays the details of each player
DisplayPlayerDetails
(
pokedexvaluespointer
,
"Alan"
);
...
...
mainpokedex.exe
View file @
4e382470
No preview for this file type
pokedexstructs.h
View file @
4e382470
...
...
@@ -16,6 +16,6 @@ typedef struct PlayerNode {
}
PlayerNode
;
//This sets the structure for the pokedex and gives it two headers
typedef
struct
Pokedex
{
P
okemonNode
*
pokemon
head
;
P
layerNode
*
player
head
;
P
layerNode
*
player
head
;
P
okemonNode
*
pokemon
head
;
}
Pokedex
;
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