Question

Check the file: Questions.pdf

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

Drivers.cpp:

#include "Hero.h"
#include <iostream>
#include <string>
#include <vector>
#include <fstream>

//Free the alocated memory for heroes
void deleteHeroes(std::vector<Hero *> list) {
Hero *hero;
for (int i = 0; i < list.size(); i++) {
hero = list[i];
hero->deletePowers(); //delete powers attached to hero
delete hero;
}
list.empty();
}

//read in file and add each hero as vector input
void loadHeroes(std::string filename, std::vector<Hero *> &list) {
Hero *hero;
std::ifstream infile(filename);
if (infile.is_open()) {
std::string newLine;
deleteHeroes(list); //empty the list for case of reloading
while (!infile.eof()) {
std::getline(infile, newLine);
hero = new Hero(newLine);
list.push_back(hero);
}
std::cout << list.size() << " heroes loaded." << std::endl;
}
//file does not exist
else {
std::cout << "File not found." << std::endl;
}
}

//iterate through heroes list and print each of their powers
void printRoster(std::vector<Hero *> list) {
std::cout << "The following " << list.size() << " heroes are loaded..." << std::endl;
for (int i = 0; i < list.size(); i++) {
std::cout << "--------------------" << std::endl;
list[i]->printPower();
}
}...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

Sort Three Numbers
Homework Solution
$8.00
Input
User
Non-Decreasing
Output
Three
Numbers
Computer Science
C-Family Programming
Matrix Multiplication
Homework Solution
$23.00
Matrix
Multiplication
Computer
Science
C-Family
Programming
Print
Results
Input
Output
Values
Label
C Code Errors Minireport
Homework Solution
$25.00
Error
C
Code
Message
Compiler
Common
Friendly
Computer Science
C-Family Programming
Programming Questions
Homework Solution
$40.00
Programming
C++
Computer Science
Strings
Codes
Characters
Pointers
Buffer
Human-Readable Information
CMYK Colors
Encoding
Issues
Compiler Errors
Assembly Language
Intel Machine
Lines
Symbols
Get help from a qualified tutor
Live Chats