Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
c_pokedex_assignment
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
elijah vasquez
c_pokedex_assignment
Commits
e4ce6059
Commit
e4ce6059
authored
Jan 17, 2023
by
elijah vasquez
🦍
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hellyeah
parent
8e533737
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
15 deletions
+19
-15
functions.h
functions.h
+11
-11
liststructure.c
liststructure.c
+8
-4
main.exe
main.exe
+0
-0
No files found.
functions.h
View file @
e4ce6059
...
...
@@ -27,21 +27,21 @@ typedef struct Pokedex // To house the header nodes to start single
// Pokemon List
PokemonNode
*
NewPokemonNode
(
char
name
[
20
],
char
type
[
20
],
char
ability
[
30
]);
void
AddPokemonToList
(
Pokedex
*
pokedex
,
char
name
[
20
],
char
type
[
20
],
char
ability
[
30
]);
PokemonNode
*
FindPokemon
(
Pokedex
*
pokedex
,
char
name
[
20
]);
PokemonNode
*
NewPokemonNode
(
char
name
[
20
],
char
type
[
20
],
char
ability
[
30
]);
// Create new pokemon
void
AddPokemonToList
(
Pokedex
*
pokedex
,
char
name
[
20
],
char
type
[
20
],
char
ability
[
30
]);
//Add pokemon to list
PokemonNode
*
FindPokemon
(
Pokedex
*
pokedex
,
char
name
[
20
]);
//Find pokemon within list
// Player List
PlayerNode
*
NewPlayerNode
(
char
name
[
50
]);
// Create new node, return pointer to node
void
AddPlayerToList
(
Pokedex
*
pokedex
,
char
name
[
50
]);
// Check if name already exists in Player list.
PlayerNode
*
FindPlayer
(
Pokedex
*
pokedex
,
char
name
[
50
]);
// Searches Player list for name.
void
AddPokemonToPlayer
(
Pokedex
*
player
,
Pokedex
*
pokemon
,
char
playerName
[
50
],
char
pokemonName
[
20
]);
// Adds Pokemon to player's Pokemon list
PlayerNode
*
NewPlayerNode
(
char
name
[
50
]);
// Create new node, return pointer to node
void
AddPlayerToList
(
Pokedex
*
pokedex
,
char
name
[
50
]);
// Check if name already exists in Player list.
PlayerNode
*
FindPlayer
(
Pokedex
*
pokedex
,
char
name
[
50
]);
// Searches Player list for name.
void
AddPokemonToPlayer
(
Pokedex
*
player
,
Pokedex
*
pokemon
,
char
playerName
[
50
],
char
pokemonName
[
20
]);
// Adds Pokemon to player's Pokemon list
// Additional
// Pokemon details
void
DisplayPokemonDetails
(
Pokedex
*
pokedex
,
char
name
[
20
]);
// Output details of pokemon
PokemonNode
*
ListPokemon
(
Pokedex
*
pokedex
);
//output list of names of all POKEMON in pokedex
void
DisplayPokemonDetails
(
Pokedex
*
pokedex
,
char
name
[
20
]);
// Output details of pokemon
PokemonNode
*
ListPokemon
(
Pokedex
*
pokedex
);
//output list of names of all POKEMON in pokedex
// Pokemon players
void
DisplayPlayerDetails
(
Pokedex
*
pokedex
,
char
name
[
50
]);
// output details of players, incl. list of names of pokemon owned
PlayerNode
*
ListPlayers
(
Pokedex
*
pokedex
);
//output list of names of all PLAYERS in pokedex
void
DisplayPlayerDetails
(
Pokedex
*
pokedex
,
char
name
[
50
]);
// output details of players, incl. list of names of pokemon owned
PlayerNode
*
ListPlayers
(
Pokedex
*
pokedex
);
//output list of names of all PLAYERS in pokedex
liststructure.c
View file @
e4ce6059
// Calling of functions
and setting up nodes
// Calling of functions
#include "functions.h"
int
main
(
void
)
{
// Adding Pokemon nodes to list
Pokedex
*
pokeHead
=
NewPokemonNode
(
"blastoise"
,
"water"
,
"torrent"
);
//
Creation of
node to introduce head of single linked list
Pokedex
*
pokeHead
=
NewPokemonNode
(
"blastoise"
,
"water"
,
"torrent"
);
//
Creation of new pokemon as
node to introduce head of single linked list
AddPokemonToList
(
pokeHead
,
"dragapult"
,
"dragon"
,
"infiltrator"
);
AddPokemonToList
(
pokeHead
,
"volcarona"
,
"fire"
,
"flame body"
);
AddPokemonToList
(
pokeHead
,
"regieleki"
,
"electric"
,
"transistor"
);
// Adding player nodes to player list
Pokedex
*
playerHead
=
NewPlayerNode
(
"armin"
);
Pokedex
*
playerHead
=
NewPlayerNode
(
"armin"
);
// Creation of new player as node to introduce head of player list
AddPlayerToList
(
playerHead
,
"chase"
);
AddPlayerToList
(
playerHead
,
"ziggy"
);
// Linking pokemon with players
AddPokemonToPlayer
(
pokeHead
,
playerHead
,
"armin"
,
"blastoise"
);
AddPokemonToPlayer
(
pokeHead
,
playerHead
,
"armin"
,
"blastoise"
);
// pointer variables from above used within parameter to assign pokemon to players
AddPokemonToPlayer
(
pokeHead
,
playerHead
,
"armin"
,
"dragapult"
);
AddPokemonToPlayer
(
pokeHead
,
playerHead
,
"chase"
,
"volcarona"
);
AddPokemonToPlayer
(
pokeHead
,
playerHead
,
"ziggy"
,
"regieleki"
);
...
...
@@ -25,6 +25,10 @@ int main(void)
ListPlayers
(
playerHead
);
// Display details of each player
/*
This section can be regarded as a dissection of ListPokemon
and ListPlayers.
*/
DisplayPlayerDetails
(
playerHead
,
"armin"
);
DisplayPlayerDetails
(
playerHead
,
"chase"
);
DisplayPlayerDetails
(
playerHead
,
"ziggy"
);
...
...
main.exe
View file @
e4ce6059
No preview for this file type
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