/*---- signature: main: void -> int purpose: testing program for the class GameDie compile using: g++ GameDieTest.cpp GameDie.cpp -o GameDieTest run using: ./GameDieTest by: Sharon Tuttle last modified: 2021-06-27 ----*/ #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include "GameDie.h" using namespace std; int main() { cout << boolalpha; // try out each constructor GameDie demo_die; GameDie deca_die(10); // testing accessors while also checking if // constructors initialized data fields // as expected cout << endl; cout << "testing constructors and accessors:" << endl; cout << (demo_die.get_num_sides() == 6) << endl; cout << (demo_die.get_curr_top() == 1) << endl; cout << (deca_die.get_num_sides() == 10) << endl; cout << (deca_die.get_curr_top() == 1) << endl; // now trying to test roll to at least SOME degree cout << endl; cout << "trying to test roll to at least SOME degree:" << endl; int rolled_result = demo_die.roll(); int deca_rolled = deca_die.roll(); // did roll properly change the calling die's top? cout << (rolled_result == demo_die.get_curr_top()) << endl; cout << (deca_rolled == deca_die.get_curr_top()) << endl; // is rolled result in expected range? cout << (rolled_result <= 6) << endl; cout << (rolled_result >= 1) << endl; cout << (deca_rolled <= 10) << endl; cout << (deca_rolled >= 1) << endl; // over 10 rolls, are rolled results in expected range? and change top? for (int i=0; i<10; i++) { rolled_result = demo_die.roll(); deca_rolled = deca_die.roll(); cout << ((rolled_result == demo_die.get_curr_top()) && (deca_rolled == deca_die.get_curr_top()) && (rolled_result <= 6) && (rolled_result >= 1) && (deca_rolled <= 10) && (deca_rolled >= 1)) << endl; } // and just to see different roll values, I hope...! cout << endl; cout << "just for fun: rolling deca_die 5 times: " << endl; for (int i=0; i<5; i++) { cout << deca_die.roll() << endl; } return EXIT_SUCCESS; }