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
3277127c
Commit
3277127c
authored
Feb 03, 2023
by
sam.pople
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
submit
parent
1c10d31f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
mainpokedex.c
mainpokedex.c
+11
-10
mainpokedex.exe
mainpokedex.exe
+0
-0
pokedexstructs.h
pokedexstructs.h
+2
-2
No files found.
mainpokedex.c
View file @
3277127c
...
...
@@ -10,12 +10,12 @@ void ListPokemon(Pokedex *pokedex)
//This assigns a node to be a head for the pokemon list
PokemonNode
*
current
=
pokedex
->
pokemonhead
;
printf
(
"
\n
List of Pokemon:
\n
"
);
while
(
current
!=
NULL
)
{
//The current node is printed and then the next is assigned.
printf
(
"%s
\n
"
,
current
->
name
);
current
=
current
->
Next
;
current
=
current
->
nextpokemon
;
}
}
//This displays the list of players
void
ListPlayers
(
Pokedex
*
pokedex
)
...
...
@@ -23,12 +23,13 @@ void ListPlayers(Pokedex* pokedex)
//The first player item is made the head
PlayerNode
*
current
=
pokedex
->
playerhead
;
printf
(
"
\n
List of Players:
\n
"
);
while
(
current
!=
NULL
)
{
printf
(
"%s
\n
"
,
current
->
name
);
current
=
current
->
Next
;
current
=
current
->
nextplayer
;
}
}
//This creates each Pokemon node
PokemonNode
*
NewPokemonNode
(
char
name
[
20
],
char
type
[
20
],
char
ability
[
50
])
...
...
@@ -37,7 +38,7 @@ PokemonNode* NewPokemonNode(char name[20], char type[20], char ability[50])
strcpy
(
addnode
->
name
,
name
);
strcpy
(
addnode
->
type
,
type
);
strcpy
(
addnode
->
ability
,
ability
);
addnode
->
Next
=
NULL
;
addnode
->
nextpokemon
=
NULL
;
return
addnode
;
}
//This creates each Player node
...
...
@@ -48,7 +49,7 @@ PlayerNode *NewPlayerNode(char name[20])
addnode
->
numofpokemon
=
0
;
memset
(
addnode
->
PokemonArray
,
NULL
,
sizeof
(
addnode
->
PokemonArray
));
addnode
->
Next
=
NULL
;
addnode
->
nextplayer
=
NULL
;
return
addnode
;
}
//This finds the Pokemon in the Pokemon list
...
...
@@ -65,7 +66,7 @@ PokemonNode* FindPokemon(PokemonNode* head, char name[20])
}
else
{
current
=
current
->
Next
;
current
=
current
->
nextpokemon
;
}
}
return
0
;
...
...
@@ -82,7 +83,7 @@ PlayerNode* FindPlayer(PlayerNode* playerhead, char name[20])
}
else
{
current
=
current
->
Next
;
current
=
current
->
nextplayer
;
}
}
return
0
;
...
...
@@ -93,7 +94,7 @@ void AddPokemonToList(Pokedex* pokedex, char name[20], char type[20], char abili
if
(
FindPokemon
(
pokedex
->
pokemonhead
,
name
)
==
0
)
{
PokemonNode
*
current
=
NewPokemonNode
(
name
,
type
,
ability
);
current
->
Next
=
pokedex
->
pokemonhead
;
current
->
nextpokemon
=
pokedex
->
pokemonhead
;
pokedex
->
pokemonhead
=
current
;
printf
(
"Pokemon %s added
\n
"
,
name
);
}
...
...
@@ -109,7 +110,7 @@ void AddPlayerToList(Pokedex* pokedex, char name[20])
if
(
FindPlayer
(
pokedex
->
playerhead
,
name
)
==
0
)
{
//If the player isnt already in the list, a new node is created
PlayerNode
*
current
=
NewPlayerNode
(
name
);
current
->
Next
=
pokedex
->
playerhead
;
current
->
nextplayer
=
pokedex
->
playerhead
;
pokedex
->
playerhead
=
current
;
printf
(
"Player %s Added
\n
"
,
name
);
}
...
...
mainpokedex.exe
View file @
3277127c
No preview for this file type
pokedexstructs.h
View file @
3277127c
...
...
@@ -4,7 +4,7 @@ typedef struct PokemonNode {
char
name
[
20
];
char
type
[
20
];
char
ability
[
50
];
struct
PokemonNode
*
Next
;
struct
PokemonNode
*
nextpokemon
;
}
PokemonNode
;
//This sets the structure variables for the player node (name, number of pokemon and Pokemon Array)
...
...
@@ -12,7 +12,7 @@ typedef struct PlayerNode {
char
name
[
20
];
int
numofpokemon
;
PokemonNode
*
PokemonArray
[
30
];
struct
PlayerNode
*
Next
;
struct
PlayerNode
*
nextplayer
;
}
PlayerNode
;
typedef
struct
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