You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on my CovidDB assignment which involves making a hash table from scratch. For this assignment I don't have any limitations/restrictions, I can use whichever library or container from the STL.
My DataEntry class consists of:
/**
* @brief DataEntry class represents a single entry of COVID-19 data
* for a particular date and country.
* @class DataEntry
* @note This class is immutable once created.
*/
class DataEntry final {
private:
std::string date;
std::string country;
int c_cases;
int c_deaths;
public:
DataEntry();
/** @note mutators and acessors*/
inline void set_date(std::string set_date) { this->date = set_date;};
inline void set_country(std::string set_country) { this->country = set_country;};
inline void set_c_deaths(int set_c_deaths) { this->c_deaths = set_c_deaths;};
inline void set_c_cases(int set_c_cases) { this->c_cases = set_c_cases;};
inline int get_c_cases() { return c_cases;};
inline int get_c_deaths() { return c_deaths;};
inline std::string get_date() { return date;};
inline std::string get_country() { return country;};
bool read_file();
};
and my CovidDB class
/**
* @brief A hash table implementation to store Covid-19 data by country
* @class CovidDB
* @note The hash table size is fixed at 17.
*/
class CovidDB final {
private:
int size = 17;
int key; //country
std::vector<std::vector<DataEntry*>> HashTable;
public:
inline CovidDB() {
HashTable.resize(size);
}
inline ~CovidDB() {
for (auto& row : HashTable) {
row.clear();
}
HashTable.clear();
}
DataEntry get(std::string country);
bool add(DataEntry* entry);
bool read_country_file();
int hash(std::string country);
void remove(std::string country);
void display_table();
};
One of my methods in my CovidDB class [add] check if the current_date is less than the entered date, if so the method should reject the entry. Here is what I got so far:
Programming HelpDiscussions around programming languages, open source and software development
1 participant
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
Hi,
I am working on my CovidDB assignment which involves making a hash table from scratch. For this assignment I don't have any limitations/restrictions, I can use whichever library or container from the STL.
My DataEntry class consists of:
and my CovidDB class
One of my methods in my CovidDB class [add] check if the current_date is less than the entered date, if so the method should reject the entry. Here is what I got so far:
For some reason, when I call the function in main the record is not being rejected, but its being added.
Can someone tell me what I did wrong, and if there is any other approach to compare dates. The date is in the format of mm/dd/yyyy
Thank you.
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions