Commit 94c98830 authored by zak.evans's avatar zak.evans

Delete main.c

parent 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment