graph.cc: coding style fixes

This commit is contained in:
Pawel "l0ner" Soltys 2015-01-17 23:48:54 +01:00
parent 1cc6b0c9ef
commit f2b75f7531
2 changed files with 32 additions and 22 deletions

@ -3,33 +3,41 @@
#include "graph.h"
char * getGraphByPercentage(unsigned value, unsigned len) {
std::string get_graph_by_percentage(unsigned value, unsigned len)
{
unsigned step = 0;
char * bars = new char[len + 1];
std::string bars;
unsigned barCount = (static_cast<float>(value) / 99.9 * len);
unsigned bar_count = (static_cast<float>(value) / 99.9 * len);
for(step; step < barCount; step++)
bars[step] = '|';
for(step; step < bar_count; step++)
{
bars.append("|");
}
for(step; step < len; step++)
bars[step] = ' ';
bars[len]='\0';
{
bars.append(" ");
}
return bars;
}
char * getGraphByValue(unsigned value, unsigned max, unsigned len) {
std::string get_graph_by_value(unsigned value, unsigned max, unsigned len)
{
unsigned step = 0;
char * bars = new char[len + 1];
std::string bars;
unsigned barCount = (static_cast<float>(value / (max - 0.1)) * len);
unsigned bar_count = (static_cast<float>(value / (max - 0.1)) * len);
for(step; step < barCount; step++)
bars[step] = '|';
for(step; step < bar_count; step++)
{
bars.append("|");
}
for(step; step < len; step++)
bars[step] = ' ';
bars[len]='\0';
{
bars.append(" ");
}
return bars;
}

@ -1,7 +1,9 @@
#ifndef GRAPH_H_
#define GRAPH_H_
char * getGraphByPercentage(unsigned, unsigned len = 10);
char * getGraphByValue(unsigned, unsigned, unsigned len = 10);
#include <string>
std::string get_graph_by_percentage(unsigned, unsigned len = 10);
std::string get_graph_by_value(unsigned, unsigned, unsigned len = 10);
#endif