/*---- signature: main: void -> int purpose: playing around with a few more standard output formatting tools compile using: g++ 112lect09-1-format.cpp PlayerChar.cpp -o 112lect09-1-format run using: ./112lect09-1-format by: Sharon Tuttle last modified: 2022-10-18 ----*/ #include <cstdlib> #include <iostream> #include <iomanip> #include <string> #include <cmath> #include <vector> #include "PlayerChar.h" using namespace std; int main() { cout << boolalpha; PlayerChar angie("Angie", 10, 2.0, "tank", 15); PlayerChar sven("Sven", 5, 3.11, "support", 14); PlayerChar alphonse("Alphonse", 25, 10.659, "armour", 30); cout << angie.get_exp() << endl; cout << sven.get_exp() << endl; cout << alphonse.get_exp() << endl; // ask that numeric values be formatted // to display 2 fractional places cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(4); cout << setw(10) << angie.get_exp() << endl; cout << setw(10) << sven.get_exp() << endl; cout << setw(10) << alphonse.get_exp() << endl; cout << "here's their hp: " << endl; cout << angie.get_hp() << endl; cout << sven.get_hp() << endl; cout << alphonse.get_hp() << endl; vector<PlayerChar> squad(3); squad[0] = angie; squad[1] = sven; squad[2] = alphonse; for (int i=0; i < squad.size(); i++) { cout << setw(10) << squad[i].get_name() << " " << setw(8) << squad[i].get_exp() << " " << setw(5) << squad[i].get_strength() << " " << setw(8) << squad[i].get_role() << endl; } return EXIT_SUCCESS; }