EstruturaDeDados
Carregando...
Procurando...
Nenhuma entrada encontrada
hours.hpp
Ir para a documentação deste ficheiro.
1#pragma once
2
3#include <string>
4
11class Hours {
12 public:
17
24 Hours(int h, int m, int s);
25
32 void set_time(int h, int m, int s);
33
38 int get_hours() const;
39
44 int get_minutes() const;
45
50 int get_seconds() const;
51
56 int to_seconds() const;
57
62 double to_minutes() const;
63
68 double to_hours() const;
69
74 std::string to_string() const;
75
79 bool operator==(const Hours& other) const;
80 bool operator!=(const Hours& other) const;
81 bool operator>(const Hours& other) const;
82 bool operator<(const Hours& other) const;
83 bool operator>=(const Hours& other) const;
84 bool operator<=(const Hours& other) const;
85
91 Hours operator+(const Hours& other) const;
92
98 Hours operator-(const Hours& other) const;
99
100 private:
101 int hours;
102 int minutes;
103 int seconds;
104
111 void normalize();
112};
Classe que representa uma quantidade de tempo no formato HH:MM:SS.
Definição hours.hpp:11
std::string to_string() const
Retorna o tempo formatado como string "HH:MM:SS".
Hours()
Construtor padrão que inicializa o tempo como 00:00:00.
int to_seconds() const
Retorna o total de segundos desde 00:00:00.
bool operator<(const Hours &other) const
int get_hours() const
Obtém a quantidade de horas.
Hours operator+(const Hours &other) const
Sobrecarga do operador + para somar dois tempos.
Hours operator-(const Hours &other) const
Sobrecarga do operador - para subtrair dois tempos.
double to_minutes() const
Retorna o total de minutos desde 00:00:00.
void set_time(int h, int m, int s)
Define um novo tempo.
bool operator>=(const Hours &other) const
Hours(int h, int m, int s)
Construtor que inicializa o tempo com valores específicos.
double to_hours() const
Retorna o total de horas desde 00:00:00.
int get_seconds() const
Obtém a quantidade de segundos.
bool operator>(const Hours &other) const
int get_minutes() const
Obtém a quantidade de minutos.
bool operator<=(const Hours &other) const
bool operator!=(const Hours &other) const
bool operator==(const Hours &other) const
Operadores de comparação entre dois objetos Hours.