#ifndef FUNCTIONS_H #define FUNCTIONS_H #include using namespace std; /// \fn validateSorts /// \~English /// \brief Function to validate that sort is invoked with non-empty strings /// \param a first QSring /// \param b second Qstring /// \param c third QString /// \return true if non of the QStrings are empty /// \~Spanish /// \brief Valida que los QStrings que se van a ordenar no estén vacios. /// \param a primer QSring /// \param b segundo Qstring /// \param c tercer QString /// \return true si ninguno de los QString está vacio bool validateSorts(const QString &a, const QString &b, const QString &c); /// \fn mySortAlpha /// \~English /// \brief A function to sort the QStrings. Returns the order /// strings through the parameters (a is smallest, c is largest). /// \param a reference to first QSring /// \param b reference to second Qstring /// \param c reference to third QString /// \~Spanish /// \brief Función para ordenar QStrings. Devuelve los QStrings /// ordenados a través de los parámetros (a para el menor, c para el mayor). /// \param a referencia al primer QSring /// \param b referencia al segundo Qstring /// \param c referencia al tercer QString void mySortAlpha(QString &a, QString &b, QString &c); /// \fn mySortBeta /// \~English /// \brief A function to sort the QStrings. Returns the order /// strings through the parameters (a is smallest, c is largest). /// \param a reference to first QSring /// \param b reference to second Qstring /// \param c reference to third QString /// \~Spanish /// \brief Función para ordenar QStrings. Devuelve los QStrings /// ordenados a través de los parámetros (a para el menor, c para el mayor). /// \param a referencia al primer QSring /// \param b referencia al segundo Qstring /// \param c referencia al tercer QString void mySortBeta(QString &a, QString &b, QString &c); /// \fn mySortGamma /// \~English /// \brief A function to sort the QStrings. Returns the order /// strings through the parameters (a is smallest, c is largest). /// \param a reference to first QSring /// \param b reference to second Qstring /// \param c reference to third QString /// \~Spanish /// \brief Función para ordenar QStrings. Devuelve los QStrings /// ordenados a través de los parámetros (a para el menor, c para el mayor). /// \param a referencia al primer QSring /// \param b referencia al segundo Qstring /// \param c referencia al tercer QString void mySortGamma(QString &a, QString &b, QString &c); /// \fn mySortDelta /// \~English /// \brief First function to sort the QStrings. Returns the order /// strings through the parameters (a is smallest, c is largest). /// \param a reference to first QSring /// \param b reference to second Qstring /// \param c reference to third QString /// \~Spanish /// \brief Función para ordenar QStrings. Devuelve los QStrings /// ordenados a través de los parámetros (a para el menor, c para el mayor). /// \param a referencia al primer QSring /// \param b referencia al segundo Qstring /// \param c referencia al tercer QString void mySortDelta(QString &a, QString &b, QString &c); /// \fn validZuluTime /// \~English /// \brief Function to validate the arguments that will be passed to the /// Zulu functions. Returns the integer hour and minutes through last two parameters. /// \param time QString that contains the time in military format. /// \param zone QString that specifies military zone. /// \param hours hours, extracted from the time parameter /// \param minutes minutes, extracted from the time parameter /// \return true if the time and zone are valid. /// \~Spanish /// \brief Función para validar los argumentos que serán pasados a /// funciones Zulu. Devuelve (como enteros) la hora y minutos a través de los /// últimos dos parámetros. /// \param time QString que contiene la hora en formato militar, e.g. "15:22" /// \param zone QString que contiene zona militar. /// \param hours horas, extraida del argumento pasado a time. /// \param minutes minutos, extraidos del argumento pasado a time. /// \return true si la hora (time) y la zona son válidas. bool validZuluTime(const QString &time, const QString &zone, int &hours, int &minutes); /// \fn zuluAlpha /// \~English /// \brief Given the hour, minutes and military zone returns the Zulu time (as a QString) /// \param hours /// \param minutes /// \param zone /// \return a QString of the Zulu time, in military time format /// \~Spanish /// \brief Dado la hora, minutos y zona militar devuelve el tiempo Zulu (como QString) /// \param hours /// \param minutes /// \param zone /// \return un QString del tiempo Zulu, en formato de hora militar. QString zuluAlpha(int hours, int minutes, char zone); /// \fn zuluBeta /// \~English /// \brief Given the hour, minutes and military zone returns the Zulu time (as a QString) /// \param hours /// \param minutes /// \param zone /// \return a QString of the Zulu time, in military time format /// \~Spanish /// \brief Dado la hora, minutos y zona militar devuelve el tiempo Zulu (como QString) /// \param hours /// \param minutes /// \param zone /// \return un QString del tiempo Zulu, en formato de hora militar. QString zuluBeta(int hours, int minutes, char zone); /// \fn zuluGamma /// \~English /// \brief Given the hour, minutes and military zone returns the Zulu time (as a QString) /// \param hours /// \param minutes /// \param zone /// \return a QString of the Zulu time, in military time format /// \~Spanish /// \brief Dado la hora, minutos y zona militar devuelve el tiempo Zulu (como QString) /// \param hours /// \param minutes /// \param zone /// \return un QString del tiempo Zulu, en formato de hora militar. QString zuluGamma(int hours, int minutes, char zone); /// \fn zuluDelta /// \~English /// \brief Given the hour, minutes and military zone returns the Zulu time (as a QString) /// \param hours /// \param minutes /// \param zone /// \return a QString of the Zulu time, in military time format /// \~Spanish /// \brief Dado la hora, minutos y zona militar devuelve el tiempo Zulu (como QString) /// \param hours /// \param minutes /// \param zone /// \return un QString del tiempo Zulu, en formato de hora militar. QString zuluDelta(int hours, int minutes, char zone); // Constants for the rock, paper, scisor functions. const int TIE = 0; const int P1_WON = 1; const int P2_WON = 2; /// \fn RPSAlpha /// \~English /// \brief Given play by the first and second players, returns who won the rock, paper /// scisors match. /// \param p1 play by the first player, as represented by char 'R', 'P' or 'S' /// \param p2 play by the first player, as represented by char 'R', 'P' or 'S' /// \return a 0 if there was a tie, 1 if the first player won, 2 if the second player won. /// \~Spanish /// \brief Dado la jugada del jugador 1 y 2, devuelve quien ganó el juego de piedra, /// papel y tijera ((R)ock, (P)aper, (S)cisors) /// \param p1 jugada del primer jugador, representada por un caracter ('R','P','S') /// \param p1 jugada del segundo jugador, representada por un caracter ('R','P','S') /// \return a 0 si hubo empate, 1 si ganó el primer jugador, 2 si ganó el segundo. int RPSAlpha(char p1, char p2); /// \fn RPSBeta /// \~English /// \brief Given play by the first and second players, returns who won the rock, paper /// scisors match. /// \param p1 play by the first player, as represented by char 'R', 'P' or 'S' /// \param p2 play by the first player, as represented by char 'R', 'P' or 'S' /// \return a 0 if there was a tie, 1 if the first player won, 2 if the second player won. /// \~Spanish /// \brief Dado la jugada del jugador 1 y 2, devuelve quien ganó el juego de piedra, /// papel y tijera ((R)ock, (P)aper, (S)cisors) /// \param p1 jugada del primer jugador, representada por un caracter ('R','P','S') /// \param p1 jugada del segundo jugador, representada por un caracter ('R','P','S') /// \return a 0 si hubo empate, 1 si ganó el primer jugador, 2 si ganó el segundo. int RPSBeta(char p1, char p2); /// \fn RPSGamma /// \~English /// \brief Given play by the first and second players, returns who won the rock, paper /// scisors match. /// \param p1 play by the first player, as represented by char 'R', 'P' or 'S' /// \param p2 play by the first player, as represented by char 'R', 'P' or 'S' /// \return a 0 if there was a tie, 1 if the first player won, 2 if the second player won. /// \~Spanish /// \brief Dado la jugada del jugador 1 y 2, devuelve quien ganó el juego de piedra, /// papel y tijera ((R)ock, (P)aper, (S)cisors) /// \param p1 jugada del primer jugador, representada por un caracter ('R','P','S') /// \param p1 jugada del segundo jugador, representada por un caracter ('R','P','S') /// \return a 0 si hubo empate, 1 si ganó el primer jugador, 2 si ganó el segundo. int RPSGamma(char p1, char p2); /// \fn RPSDelta /// \~English /// \brief Given play by the first and second players, returns who won the rock, paper /// scisors match. /// \param p1 play by the first player, as represented by char 'R', 'P' or 'S' /// \param p2 play by the first player, as represented by char 'R', 'P' or 'S' /// \return a 0 if there was a tie, 1 if the first player won, 2 if the second player won. /// \~Spanish /// \brief Dado la jugada del jugador 1 y 2, devuelve quien ganó el juego de piedra, /// papel y tijera ((R)ock, (P)aper, (S)cisors) /// \param p1 jugada del primer jugador, representada por un caracter ('R','P','S') /// \param p1 jugada del segundo jugador, representada por un caracter ('R','P','S') /// \param zone /// \return a 0 si hubo empate, 1 si ganó el primer jugador, 2 si ganó el segundo. int RPSDelta(char p1, char p2); /// \fn initCheckWMaps /// \~English /// \brief Initialize the values in the dictionary (M) that is used throughout /// the check functions. /// \~Spanish /// \brief Inicializa los valores del diccionario que se utiliza a través del /// las funciones 'check' void initCheckWMaps(); /// \fn validateCheckQty /// \~English /// \brief Given a QString determines its numerical value and if the /// the value is in the range [0,999999999] /// \param st a QString with a numeric value, e.g. "4520" /// \param qty unsigned integer to return the numeric value, e.g. 4520 /// \return true if the QString was converted to an integer and is in the valid range /// \~Spanish /// \brief Dado un string determina su valor numérico y si el valor está en el /// rango [0,999999999] /// \param st un QString con un valor numérico, e.g. "4520" /// \param qty entero sin signo para devolver el valor numérico, e.g. 4520 /// \return true si el QString se pudo convertir a entero y está en el rango bool validateCheckQty(QString st, unsigned int &qty); /// \fn wordForNumber /// \~English /// \brief Given a number n in [0,999] returns the word equivalent /// \param n the unsigned integer, e.g. 34 /// \return a QString containing the number in words, e.g. "thirty four" /// \~Spanish /// \brief Dado un número entero en el rango [0,999] devuelve su representación en palabras /// \param n el entero sin signo, e.g. 34 /// \return un QString que contiene el valor en palabras, e.g. "thirty four" QString wordForNumber(unsigned int n); /// \fn checkWAlpha /// \~English /// \brief Given a unsigned integer returns its value as a string of words (in English) /// \param n the unsigned integer, e.g. 42 /// \return QString containing the value (in words), e.g. "fourty two" /// \~Spanish /// \brief Dado un entero sin signo devuelve su valor como un string de palabras (in English) /// \param n el entero sin signo, e.g. 42 /// \return QString que contien el valor en palabras, e.g. "fourty two" QString checkWAlpha(unsigned int n); /// \fn checkWBeta /// \~English /// \brief Given a unsigned integer returns its value as a string of words (in English) /// \param n the unsigned integer, e.g. 42 /// \return QString containing the value (in words), e.g. "fourty two" /// \~Spanish /// \brief Dado un entero sin signo devuelve su valor como un string de palabras (in English) /// \param n el entero sin signo, e.g. 42 /// \return QString que contien el valor en palabras, e.g. "fourty two" QString checkWBeta(unsigned int n); /// \fn checkWGamma /// \~English /// \brief Given a unsigned integer returns its value as a string of words (in English) /// \param n the unsigned integer, e.g. 42 /// \return QString containing the value (in words), e.g. "fourty two" /// \~Spanish /// \brief Dado un entero sin signo devuelve su valor como un string de palabras (in English) /// \param n el entero sin signo, e.g. 42 /// \return QString que contien el valor en palabras, e.g. "fourty two" QString checkWGamma(unsigned int n); /// \fn checkWDelta /// \~English /// \brief Given a unsigned integer returns its value as a string of words (in English) /// \param n the unsigned integer, e.g. 42 /// \return QString containing the value (in words), e.g. "fourty two" /// \~Spanish /// \brief Dado un entero sin signo devuelve su valor como un string de palabras (in English) /// \param n el entero sin signo, e.g. 42 /// \return QString que contien el valor en palabras, e.g. "fourty two" QString checkWDelta(unsigned int n); #endif // FUNCTIONS_H