Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Pokedex New
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
zak.evans
Pokedex New
Commits
1dd56a94
Commit
1dd56a94
authored
Mar 23, 2023
by
zak.evans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
0 deletions
+103
-0
main.c
main.c
+103
-0
No files found.
main.c
0 → 100644
View file @
1dd56a94
#include <iostream>
#include <string>
using
namespace
std
;
// Pokemon struct
struct
Pokemon
{
string
name
;
int
number
;
string
type
;
int
level
;
bool
isCaptured
;
bool
isFavorited
;
Pokemon
*
next
;
// Pointer to next Pokemon in linked list
};
// Player struct
struct
Player
{
string
name
;
int
age
;
Player
*
next
;
// Pointer to next Player in linked list
Pokemon
*
pokemonList
;
// Pointer to the first Pokemon in the linked list of the player's captured Pokemon
};
// Main function
int
main
()
{
// Create a linked list of Pokemon
Pokemon
*
bulbasaur
=
new
Pokemon
();
bulbasaur
->
name
=
"Bulbasaur"
;
bulbasaur
->
number
=
1
;
bulbasaur
->
type
=
"Grass/Poison"
;
bulbasaur
->
level
=
7
;
bulbasaur
->
isCaptured
=
false
;
bulbasaur
->
isFavorited
=
false
;
Pokemon
*
charmander
=
new
Pokemon
();
charmander
->
name
=
"Charmander"
;
charmander
->
number
=
4
;
charmander
->
type
=
"Fire"
;
charmander
->
level
=
24
;
charmander
->
isCaptured
=
false
;
charmander
->
isFavorited
=
true
;
bulbasaur
->
next
=
charmander
;
charmander
->
next
=
nullptr
;
// Create a linked list of players
Player
*
zak
=
new
Player
();
zak
->
name
=
"Zak"
;
zak
->
age
=
19
;
zak
->
pokemonList
=
nullptr
;
Player
*
will
=
new
Player
();
will
->
name
=
"Will"
;
will
->
age
=
11
;
will
->
pokemonList
=
nullptr
;
zak
->
next
=
will
;
will
->
next
=
nullptr
;
// Assign Pokemon to players
zak
->
pokemonList
=
bulbasaur
;
will
->
pokemonList
=
nullptr
;
// Will doesn't have any Pokemon
// Display the Pokedex
cout
<<
"POKEMON:"
<<
endl
;
Pokemon
*
currentPokemon
=
bulbasaur
;
while
(
currentPokemon
!=
nullptr
)
{
cout
<<
currentPokemon
->
name
<<
" #"
<<
currentPokemon
->
number
<<
endl
;
cout
<<
"Type: "
<<
currentPokemon
->
type
<<
endl
;
cout
<<
"Level: "
<<
currentPokemon
->
level
<<
endl
;
cout
<<
"Captured: "
<<
boolalpha
<<
currentPokemon
->
isCaptured
<<
endl
;
cout
<<
"Favorited: "
<<
boolalpha
<<
currentPokemon
->
isFavorited
<<
endl
;
cout
<<
endl
;
currentPokemon
=
currentPokemon
->
next
;
}
cout
<<
"PLAYERS:"
<<
endl
;
Player
*
currentPlayer
=
zak
;
while
(
currentPlayer
!=
nullptr
)
{
cout
<<
currentPlayer
->
name
<<
" (age "
<<
currentPlayer
->
age
<<
")"
<<
endl
;
cout
<<
"Pokemon:"
<<
endl
;
Pokemon
*
currentPokemon
=
currentPlayer
->
pokemonList
;
if
(
currentPokemon
==
nullptr
)
{
cout
<<
"None"
<<
endl
;
}
else
{
while
(
currentPokemon
!=
nullptr
)
{
cout
<<
"- "
<<
currentPokemon
->
name
<<
endl
;
currentPokemon
=
currentPokemon
->
next
;
}
}
cout
<<
endl
;
currentPlayer
=
currentPlayer
->
next
;
}
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