-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFile.cpp
More file actions
21 lines (19 loc) · 767 Bytes
/
File.cpp
File metadata and controls
21 lines (19 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "File.h"
File::File() {}; // Initialize members to default values
File::~File() {}
std::string File::printSize() const{
std::string size = std::to_string(this->getSize()); // code based on: https://stackoverflow.com/questions/7276826/format-number-with-commas-in-c
int n = size.length() - 3;
while (n > 0) {
size.insert(n, ",");
n -= 3;
}
while (size.length() < 18) { // probably a better way to implement this using an array?
size = " " + size;
}
return size;
}
void File::printDetails() const { // Add 'const' keyword if method does not modify any class members
std::cout << this->getTime() << this->printSize() << " " << this->getName() << std::endl;
}
bool File::isFile() const { return true; }