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
f6c18628
Commit
f6c18628
authored
Jan 17, 2023
by
elijah vasquez
🦍
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reorganisation
parent
0dbf6af5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
64 deletions
+67
-64
functioncall.c
functioncall.c
+41
-0
functions.h
functions.h
+24
-22
main.c
main.c
+2
-40
tempCodeRunnerFile.h
tempCodeRunnerFile.h
+0
-2
No files found.
functioncall.c
0 → 100644
View file @
f6c18628
// Calling of functions and setting up nodes
#include "functions.h"
int
main
(
void
)
{
// Adding Pokemon to list
Pokedex
*
pokeHead
=
NewPokemonNode
(
"blastoise"
,
"water"
,
"torrent"
);
//Creation of 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 to player list
Pokedex
*
playerHead
=
NewPlayerNode
(
"armin"
);
AddPlayerToList
(
playerHead
,
"chase"
);
AddPlayerToList
(
playerHead
,
"ziggy"
);
// Adding pokemon to player
AddPokemonToPlayer
(
pokeHead
,
playerHead
,
"armin"
,
"blastoise"
);
AddPokemonToPlayer
(
pokeHead
,
playerHead
,
"armin"
,
"dragapult"
);
AddPokemonToPlayer
(
pokeHead
,
playerHead
,
"chase"
,
"dragapult"
);
AddPokemonToPlayer
(
pokeHead
,
playerHead
,
"chase"
,
"regieleki"
);
AddPokemonToPlayer
(
pokeHead
,
playerHead
,
"chase"
,
"volcarona"
);
AddPokemonToPlayer
(
pokeHead
,
playerHead
,
"ziggy"
,
"regieleki"
);
// To display all of both pokemon and players
ListPokemon
(
pokeHead
);
ListPlayers
(
playerHead
);
// Display details of each player
DisplayPlayerDetails
(
playerHead
,
"armin"
);
DisplayPlayerDetails
(
playerHead
,
"chase"
);
DisplayPlayerDetails
(
playerHead
,
"ziggy"
);
// Details of each pokemon
DisplayPokemonDetails
(
pokeHead
,
"blastoise"
);
DisplayPokemonDetails
(
pokeHead
,
"dragapult"
);
DisplayPokemonDetails
(
pokeHead
,
"volcarona"
);
DisplayPokemonDetails
(
pokeHead
,
"regieleki"
);
return
0
;
}
functions.h
View file @
f6c18628
// Structs and functions placed here
// Pokemon List
// Pokemon List
typedef
struct
PokemonNode
typedef
struct
PokemonNode
{
{
char
name
[
1
2
];
char
name
[
1
00
];
char
type
[
2
0
];
char
type
[
10
0
];
char
ability
[
25
];
char
ability
[
100
];
struct
PokemonNode
*
next
;
struct
PokemonNode
*
next
;
}
PokemonNode
;
}
PokemonNode
;
// Player List
// Player List
typedef
struct
PlayerNode
typedef
struct
PlayerNode
{
{
char
name
[
25
];
char
name
[
100
];
int
totalPokemon
;
int
totalPokemon
;
PokemonNode
*
PokemonArray
[
20
];
PokemonNode
*
PokemonArray
[
100
];
//Array of players
struct
PlayerNode
*
next
;
struct
PlayerNode
*
next
;
}
PlayerNode
;
}
PlayerNode
;
// Pokedex structure
// Pokedex structure
typedef
struct
Pokedex
typedef
struct
Pokedex
{
{
PokemonNode
*
poke
monNodeh
ead
;
PokemonNode
*
poke
H
ead
;
PlayerNode
*
PlayerNodeh
ead
;
PlayerNode
*
playerH
ead
;
}
Pokedex
;
}
Pokedex
;
// Pokemon List functions
// Pokemon List functions
PokemonNode
*
NewPokemonNode
(
Pokedex
*
pokedex
,
char
name
[
25
],
char
type
[
25
],
char
ability
[
3
0
]);
PokemonNode
*
NewPokemonNode
(
char
name
[
100
],
char
type
[
100
],
char
ability
[
10
0
]);
void
AddPokemonToList
(
Pokedex
*
*
pokedex
,
char
name
[
25
],
char
type
[
25
],
char
ability
[
3
0
]);
void
AddPokemonToList
(
Pokedex
*
funct
,
char
name
[
100
],
char
type
[
100
],
char
ability
[
10
0
]);
PokemonNode
*
FindPokemon
(
Pokedex
*
pokedex
,
char
name
[
25
]);
PokemonNode
*
FindPokemon
(
Pokedex
*
funct
,
char
name
[
100
]);
// Player List functions
// Player List functions
PlayerNode
*
NewPlayerNode
(
char
name
[
50
]);
// Create new node, return pointer to node
PlayerNode
*
NewPlayerNode
(
char
name
[
100
]);
// Create new node, return pointer to node
void
AddPlayerToList
(
Pokedex
*
pokedex
,
char
name
[
50
]);
// Check if name already exists in Player list.
void
AddPlayerToList
(
Pokedex
*
funct
,
char
name
[
100
]);
// Check if name already exists in Player list.
PlayerNode
*
FindPlayer
(
Pokedex
*
pokedex
,
char
name
[
50
]);
// Searches Player list for name.
PlayerNode
*
FindPlayer
(
Pokedex
*
funct
,
char
name
[
100
]);
// Searches Player list for name.
void
AddPokemonToPlayer
(
Pokedex
*
funct
,
Pokedex
*
funct2
,
char
playerName
[
100
],
char
pokemonName
[
100
]);
// Adds Pokemon to player's Pokemon list
// Additional functions
// Additional functions for the pokedex
void
AddPokemonToPlayer
(
Pokedex
*
pokedex
,
char
playerName
[
50
],
char
pokemonName
[
20
]);
// Adds Pokemon to player's Pokemon list
// Pokemon details functs
void
DisplayPokemonDetails
(
Pokedex
*
pokedex
,
char
name
[
20
]);
// Output details of pokemon
void
DisplayPokemonDetails
(
Pokedex
*
funct
,
char
name
[
100
]);
// Output details of pokemon
void
DisplayPlayerDetails
(
Pokedex
*
pokedex
,
char
name
[
20
]);
// output details of players, incl. list of names of pokemon owned
PokemonNode
*
ListPokemon
(
Pokedex
*
funct
);
//output list of names of all POKEMON in pokedex
void
ListPokemon
(
Pokedex
*
pokedex
);
//output list of names of all POKEMON in pokedex
void
ListPlayers
(
Pokedex
*
pokedex
);
//output list of names of all PLAYERS in pokedex
// Pokemon players functs
void
AddToPokemonArray
(
Pokedex
*
pokedex
,
char
namePoke
[
20
],
char
namePlayer
[
50
]);
void
DisplayPlayerDetails
(
Pokedex
*
funct
,
char
name
[
100
]);
// output details of players, incl. list of names of pokemon owned
PlayerNode
*
ListPlayers
(
Pokedex
*
funct
);
//output list of names of all PLAYERS in pokedex
main.c
View file @
f6c18628
#include <stdio.h>
// Main: setting up nodes and printing
#include <stdlib.h>
#include "functioncall.c"
#include <string.h>
#include <stdbool.h>
#include "functions.h"
int
main
(
void
)
{
Pokedex
*
pokedex
=
NULL
;
pokedex
=
malloc
(
sizeof
(
pokedex
));
pokedex
->
pokemonNodehead
=
NULL
;
pokedex
->
PlayerNodehead
=
NULL
;
// Adding Pokemon to list
AddPokemonToList
(
&
pokedex
,
"blastoise"
,
"water"
,
"torrent"
);
AddPokemonToList
(
&
pokedex
,
"dragapult"
,
"dragon"
,
"infiltrator"
);
AddPokemonToList
(
&
pokedex
,
"volcarona"
,
"fire"
,
"flame body"
);
AddPokemonToList
(
&
pokedex
,
"regieleki"
,
"electric"
,
"transistor"
);
// Adding player to player list
AddPlayerToList
(
&
pokedex
,
"armin"
);
AddPlayerToList
(
&
pokedex
,
"chase"
);
AddPlayerToList
(
&
pokedex
,
"ziggy"
);
// Adding pokemon to player
AddPokemonToPlayer
(
pokedex
,
"armin"
,
"blastoise"
);
AddPokemonToPlayer
(
pokedex
,
"armin"
,
"dragapult"
);
AddPokemonToPlayer
(
pokedex
,
"chase"
,
"dragapult"
);
AddPokemonToPlayer
(
pokedex
,
"chase"
,
"regieleki"
);
AddPokemonToPlayer
(
pokedex
,
"chase"
,
"volcarona"
);
AddPokemonToPlayer
(
pokedex
,
"ziggy"
,
"regieleki"
);
ListPokemon
(
pokedex
);
ListPlayers
(
pokedex
);
return
0
;
}
tempCodeRunnerFile.h
deleted
100644 → 0
View file @
0dbf6af5
har
name
[
20
]);
void
DisplayPlayerDetails
(
Pokedex
*
pokedex
,
ch
\ No newline at end of file
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