Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
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
a-j.towse
Pokedex_Assignment
Commits
56d543e5
Commit
56d543e5
authored
Jan 01, 2023
by
a-j.towse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NewPokemonNode Function created
parent
2a43be28
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
14 deletions
+32
-14
a.out
a.out
+0
-0
main
main
+0
-0
main.c
main.c
+32
-14
No files found.
a.out
0 → 100755
View file @
56d543e5
File added
main
0 → 100755
View file @
56d543e5
File added
main.c
View file @
56d543e5
...
@@ -11,42 +11,42 @@ A-J Towse
...
@@ -11,42 +11,42 @@ A-J Towse
//Create struct Pokedex with a pointer to head of Pokemon and head of Player
//Create struct Pokedex with a pointer to head of Pokemon and head of Player
//Create variable of type Pokedex called pokedex.
//Create variable of type Pokedex called pokedex.
typedef
struct
Pokedex
{
typedef
struct
Pokedex
{
struct
Pokemon
*
head
;
struct
Pokemon
*
Pokemon
head
;
struct
Player
*
head
;
struct
Player
*
Player
head
;
struct
Pokedex
*
pokedex
;
struct
Pokedex
*
pokedex
;
};
}
Pokedex
;
//Create struct PokemonNode with name,type,ability variables
//Create struct PokemonNode with name,type,ability variables
//Create variables of type PokemonNode to store next and previous node in DLL
//Create variables of type PokemonNode to store next and previous node in DLL
typedef
struct
PokemonNode
{
typedef
struct
PokemonNode
{
char
name
[
2
0
];
char
name
[
5
0
];
char
type
[
1
0
];
char
type
[
5
0
];
char
ability
[
3
0
];
char
ability
[
5
0
];
struct
PokemonNode
*
next
;
struct
PokemonNode
*
next
;
struct
PokemonNode
*
prev
;
struct
PokemonNode
*
prev
;
};
}
PokemonNode
;
//Create struct PlayerNode wiith name, pokemonCount, and an array of pointers to pokemon owned called pokemonList
//Create struct PlayerNode wiith name, pokemonCount, and an array of pointers to pokemon owned called pokemonList
//Create variables of type PlayerNode to store next and previous node in DLL
//Create variables of type PlayerNode to store next and previous node in DLL
typedef
struct
PlayerNode
{
typedef
struct
PlayerNode
{
char
name
[
2
0
];
char
name
[
5
0
];
int
pokemonCount
;
int
pokemonCount
;
struct
PlayerNode
*
next
;
struct
PlayerNode
*
next
;
struct
PlayerNode
*
prev
;
struct
PlayerNode
*
prev
;
struct
PokemonNode
pokemonList
[];
struct
PokemonNode
pokemonList
[];
};
}
PlayerNode
;
//Define functions for PokemonNode struct
//Define functions for PokemonNode struct
struct
PokemonNode
*
NewPokemonNode
(
char
name
,
char
type
,
char
ability
);
struct
PokemonNode
*
NewPokemonNode
(
char
name
[],
char
type
[],
char
ability
[]
);
void
AddPokemonToList
(
struct
Pokedex
*
pokedex
,
char
name
,
char
type
,
char
ability
);
void
AddPokemonToList
(
struct
Pokedex
*
pokedex
,
char
name
,
char
type
,
char
ability
);
struct
PokemonNode
*
FindPokemon
(
struct
Pokedex
pokedex
,
char
name
);
struct
PokemonNode
*
FindPokemon
(
struct
Pokedex
pokedex
,
char
name
);
//Define functions for PlayerNode struct
//Define functions for PlayerNode struct
struct
PlayerNode
*
NewPlayerNode
(
char
name
);
struct
PlayerNode
*
NewPlayerNode
(
char
name
);
void
AddPlayerToList
(
struct
Pokedex
*
pokedex
,
char
name
);
void
AddPlayerToList
(
struct
Pokedex
*
pokedex
,
char
name
);
struct
PlayerNode
*
FindPlayer
(
struct
Pokedex
pokedex
,
char
name
);
struct
PlayerNode
*
FindPlayer
(
struct
Pokedex
pokedex
,
char
name
);
//Define functions for other functionality
//Define functions for other functionality
void
AddPokemonToPlayer
(
struct
Pokedex
pokedex
,
char
Playername
,
char
pokemonName
);
void
AddPokemonToPlayer
(
struct
Pokedex
pokedex
,
char
Playername
,
char
pokemonName
);
...
@@ -55,9 +55,27 @@ void DiplayPlayerDetails(struct Pokedex pokedex, char name);
...
@@ -55,9 +55,27 @@ void DiplayPlayerDetails(struct Pokedex pokedex, char name);
void
ListPokemon
(
struct
Pokedex
pokedex
);
void
ListPokemon
(
struct
Pokedex
pokedex
);
void
ListPlayers
(
struct
Pokedex
pokedex
);
void
ListPlayers
(
struct
Pokedex
pokedex
);
//Create NewPokemonNode function - returns variable of type PokemonNode
struct
PokemonNode
*
NewPokemonNode
(
char
name
[],
char
type
[],
char
ability
[]
)
{
int
main
()
{
struct
PokemonNode
*
newNode
=
NULL
;
//Create a pointer to a PokemonNode structure, NULL for safety
newNode
=
malloc
(
sizeof
(
struct
PokemonNode
));
//Assign memory space for PokemonNode
if
(
newNode
!=
NULL
)
{
//Ensure it exists
strcpy
(
newNode
->
name
,
name
);
//Set name
strcpy
(
newNode
->
type
,
type
);
//Set type
strcpy
(
newNode
->
ability
,
ability
);
//Set ability
newNode
->
next
=
NULL
;
//Set next pointer to NULL
newNode
->
prev
=
NULL
;
//Set prev pointer to NULL
}
return
newNode
;
}
int
main
(
void
)
{
NewPokemonNode
(
"Charmander"
,
"Fire"
,
"FireBallz"
);
return
0
;
return
0
;
...
...
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