Repository navigation
Expand file tree
/
Copy pathpokedex.cpp
More file actions
102 lines (90 loc) · 3.58 KB
/
Copy pathpokedex.cpp
File metadata and controls
102 lines (90 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*********************************************************************
** Program Filename: pokedex.cpp
** Author: Bradley Rule
** Date: January 23rd, 2022
** Description: implementation file for pokedex
** Input: name, number of pokemon, list of pokemon
** Output: number of pokemon, list of pokemon
*********************************************************************/
#include "pokedex.h"
#include "pokemon.h"
using namespace std;
/*********************************************************************
** Function: constructor
** Description: sets up base information for the pokedex
** Parameters: name of owner (string)
** Pre-Conditions: none
** Post-Conditions: will want to fill the pokedex
*********************************************************************/
Pokedex::Pokedex(string name, int total_pokemon){
this->name = name;
this->total_pokemon = total_pokemon;
}
/*********************************************************************
** Function: ad_list
** Description: overwrites the current list of pokemon with a new list
** Parameters: list of pokemon objects, size of list (int)
** Pre-Conditions: Must not already have a list of pokemon
** Post-Conditions: none
*********************************************************************/
void Pokedex::add_list(Pokemon * pokemon_list){
this->pokemon_list = pokemon_list;
}
/*********************************************************************
** Function: add_pokemon
** Description: adds a new pokemon to the pokemon_list variable
** Parameters: a Pokemon object
** Pre-Conditions: must have a fully created pokemon
** Post-Conditions: none
*********************************************************************/
void Pokedex::add_pokemon(Pokemon* pokemon){
total_pokemon++;
Pokemon* temp;
cout << "0" << endl; // DELETE LATER
temp = new Pokemon[total_pokemon];
cout << "1" << endl; // DELETE LATER
for(int i = 0; i < total_pokemon - 1; i++){
temp[i] = pokemon_list[i];
}
cout << "2" << endl; // DELETE LATER
temp[total_pokemon - 1] = *pokemon;
cout << "3" << endl; // DELETE LATER
delete[] pokemon_list;
cout << "4" << endl; // DELETE LATER
pokemon_list = temp;
cout << "5" << endl; // DELETE LATER
}
/*********************************************************************
** WIP **
** Function: print_pokemon
** Description: prints out the entire list of pokemon in the dex
** Parameters: none
** Pre-Conditions: must have pokemon in the dex
** Post-Conditions: none
** notes: impoted from lab2 must make work with new requirements
*********************************************************************/
void Pokedex::print_pokemon(){
cout << this->total_pokemon << " problem";
for(int i = 0; i < this->total_pokemon; i++){
cout << "Number: " << this->pokemon_list[i].get_number() << endl;
cout << "Name: " << this->pokemon_list[i].get_name() << endl;
cout << "Type: " << this->pokemon_list[i].get_type() << endl;
string temp[4];
for(int j = 0; j < 4; j++){
temp[j] = this->pokemon_list[i].get_moves(j);
}
cout << "Moves: " << temp[0] << ", " << temp[1] << ", " << temp[2] << ", " << temp[3] << endl << endl;
}
}
int Pokedex::get_num(){
return this->total_pokemon;
}
/*
Pokemon Pokedex::search_number(int number){
for(int i = 0; i < this->total_pokemon; i++){
if(pokemon_list[i].get_number() == number){
return pokemon_list[i];
}
}
}
*/