Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Pokedex Programming 3
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
luke.scott
Pokedex Programming 3
Commits
d1531612
Commit
d1531612
authored
Jan 17, 2023
by
luke.scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
141 additions
and
0 deletions
+141
-0
main.c
main.c
+141
-0
No files found.
main.c
0 → 100644
View file @
d1531612
#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
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