Skip to content
Snippets Groups Projects
Commit 1867f30f authored by speedson's avatar speedson
Browse files

finish changes

parent 3b4ad3e5
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,18 @@
This project aims to build a [Bar Chart](https://en.wikipedia.org/wiki/Bar_chart) Race, executed in text mode via terminal.
In the development of this program was used architecture game loop. basically formed by three main functions: process, update and render. To more info about game loop [click here](http://gameprogrammingpatterns.com/game-loop.html).
This program need a file with format CSV file, where your data is separate by commas.
#### To compile the program use Make file
| Command | Description |
| ------- | --------- |
| `make all` | Compile all files. |
| `make objFolder` | Create bin folder. |
| `make bcr` | Create executable file(need *.o files, compilable in `make all`). |
| `make bin/main.o` | `Build the main` object. |
| `make clear` | Remove all *.o and bin file. |
###### Author Edson Cassiano. October, 2020
No preview for this file type
No preview for this file type
No preview for this file type
/*!
*
* \file bcr.h
* \author Edson Cassiano
* \date November, 1st
*/
#ifndef BCR_H
#define BCR_H
#include <vector>
/*!
* BarChart class that saves one chart date
*
*/
class BarChart{
private:
int m_count;
int m_value;
std::string m_name;
std::string m_category;
std::string m_count; /*< Used in Stamp of bar chart */
std::string m_value; /*< Used to order the bar charts */
std::string m_name; /*< Save name of bar */
std::string m_category; /*< save the category of bar */
public:
BarChart(int count, int value, std::string name, std::string category);
void setBarChart(int count, int value, std::string name, std::string category);
void setCount(int count);
void setValue(int value);
void setNameBar(std::string name);
void setCategory(std::string category);
int getCount(int count){ return m_count; }
int getValue(int value){ return m_value; }
std::string getNameBar(std::string name){ return m_name; }
std::string getCategory(std::string category){ return m_category; }
};
/*!
* Default Constructor
*/
BarChart(std::string count="", std::string value="", std::string name="", std::string category="");
/*!
* Function aux used in the Constructor
*
* This function is used only to access the private members when to start de class, via constructor
*
* \param count Stamp of bar Chart
* \param value Value used to order the bar Chart
* \param name Name of Bar
* \param category Category of Bar
*
*/
void setBarChart(std::string count, std::string value, std::string name, std::string category);
void setCount(std::string count); /*< Change value of stamp */
void setValue(std::string value); /*< Change value of Bar */
void setNameBar(std::string name); /*< Change value of name Bar */
void setCategory(std::string category);/*< Change value of Category */
std::string getCount(){ return m_count; } /*< get value of title */
std::string getValue(){ return m_value; } /*< get value of bar */
std::string getNameBar(){ return m_name; } /*< get value of Name Bar */
std::string getCategory(){ return m_category; } /*< get value of Category */
};
/*!
* AnimationManage is the class with management program
*
* All action treated here, process, update, render, sort bar chart
* also management the flow of screens.
* Frame Rate is between [1, 24], default value is 24, the user can be adjusted in command line, if user uses a number out of range, the program takes on default value.
* Number of Bar in Screen, default is 12, between [1, 14] and the user can be adjusted in command line, is user uses a number out of range, the program takes on default value.
*
*/
class AnimationManage{
private:
int m_frameRate;
int m_numberOfBar;
std::string m_fileName;
std::string m_title;
std::string m_subtitle;
std::string m_source;
std::vector<BarChart> bChart;
int m_frameRate;/*< Frame Rate */
int m_numberOfBar;/*< Number of Bar in Screen */
int m_numberOfChart;/*< Number of Chart Groups */
int m_numberOfItems;/*< Number of Items in the Chart Groups */
int m_currentBarChart;/*< Current Chart count being processed */
int m_animationStage;/*< Animation Stage controls the screen and the stage of animation */
std::string m_fileName;/*< File name */
std::string m_title;/*< Title of Bar Chart */
std::string m_subtitle;/*< Subtitle of Bar Chart */
std::string m_source;/*< Information source */
std::ifstream file;/*< File with dates */
std::vector<std::string> timeStamp;/*< Vector with the Stamp to be printed */
std::vector<std::string> categorySubtitle;/*< Vector with the category of subtitle to be printed and select color */
std::vector<std::vector<BarChart>> bChart;/*< Vector with all dates about Bar Charts */
public:
//Constructor
AnimationManage(int frameRate=24, int numberOfBar=5);
/*!
*
* Default construct of Class
*
*/
AnimationManage(int frameRate=24, int numberOfBar=12);
/*!
* Function aux used in the Constructor
*
* This function is used only to access the private members when to start de class, via constructor
*
* \param frameRate Frame Rate
* \param numberOfBar Number of Bar that will show on the screen
*
*/
void setAnimationManage(int frameRate, int numberOfBar);
void setFrameRate(int frameRate);
void setNumberOfBar(int numberOfBar);
void setFileName(std::string fileName);
void setTitle(std::string title);
void setSubtitle(std::string subtitle);
void setSource(std::string source);
int getFrameRate(){ return m_frameRate; }
int getNumberOfBar(){ return m_numberOfBar; }
std::string getFileName(){ return m_fileName; }
std::string getTitle(){ return m_title; }
std::string getSubtitle(){ return m_subtitle; }
std::string getSource(){ return m_source; }
//Nessa função eu preciso abrir o arquivo apartir da linha de commando, tratando os erros
//erros: arquivo nao encontrado, parametros invalidos
void setFrameRate(int frameRate); /*< Change Frame Rate */
void setNumberOfBar(int numberOfBar); /*< Change Number Of Bar that will show on the screen*/
void setNumberOfChart(int numberOfChart);/*< Change Number of Charts */
void setNumberOfItems(int numberOfItems); /*< Change number of Items */
void setCurrentBarChart(int currentBarChart); /*< Change the Current Bar Chart count */
void setAnimationStage(int animationStage);/*< Change Stage of Animation */
void setFileName(std::string fileName);/*< Change name of file */
void setTitle(std::string title);/*< Change title of Bar */
void setSubtitle(std::string subtitle);/*< Change subtitle of Bar */
void setSource(std::string source);/*< Change information source */
int getFrameRate(){ return m_frameRate; } /*< Get frame rate */
int getNumberOfBar(){ return m_numberOfBar; } /*< Get number of Bar */
int getNumberOfChart(){ return m_numberOfChart; } /*< Get number of Chart */
int getNumberOfItems(){ return m_numberOfItems; } /*< Get number of items */
int getCurrentBarChart(){ return m_currentBarChart; } /*< get the current Bar Chart */
int getAnimationStage(){ return m_animationStage; } /*< get current stage of animation */
std::string getFileName(){ return m_fileName; } /*< get file name */
std::string getTitle(){ return m_title; } /*< get title of Chart */
std::string getSubtitle(){ return m_subtitle; } /*< get subtitle Chart */
std::string getSource(){ return m_source; } /*< get information source Chart */
int addCurrentBarChart(){ return ++m_currentBarChart; } /*< next Bar Chart */
/*!
* Enum controll Animation Stage
*/
enum AnimationStage{
START = 0, /*< 0 First process Screen */
WELCOME_MSG, /*< 1 Show Welcome message */
PROCESS_INPUT, /*< 2 Process file input */
INPUT_READ, /*< 3 Show the message about process file */
FILE_INFO, /*< 4 Show files infos */
SETUP_INFO, /*< 5 Show the setup info(frame rate and number of bar) */
STAY_INPUT, /*< 6 Stay <enter> to continue */
RUN, /*< 7 Read input file and print */
EXIT /*< 8 How much the file was read */
};
/*!
*
* Handles the input provided by user and show error message
*
* \param argc count of command in commad line
* \param argv list of command save in the char list
*
*/
void initialize(int argc, char *argv[]);
void process(void);
};
void welcome_msg(void); /*< Show Welcome message */
void read_file(void); /*< Read file provided by user */
void sort(std::vector<BarChart> &chart); /*< sort the bar Chart using bubble sort */
void process(void); /*< process file */
void update(void); /*< update flow screens */
void render(void);/*< print the current screen */
bool exit(); /*< used to exit of program when all bar Chart is read */
};
#endif
/*!
*
* \file text_color.h
* \author Selan
* \date October, 12th
*/
#ifndef COLOR_H
#define COLOR_H
#include <sstream>
using std::ostringstream;
#include <string>
using std::string;
namespace Color {
//=== Color attribute
static constexpr short RED{ 31 };
static constexpr short GREEN{ 32 };
static constexpr short YELLOW{ 33 };
static constexpr short BLUE{ 34 };
static constexpr short MAGENTA{ 35 };
static constexpr short CYAN{ 36 };
static constexpr short WHITE{ 37 };
static constexpr short BRIGHT_RED{ 91 };
static constexpr short BRIGHT_GREEN{ 92 };
static constexpr short BRIGHT_YELLOW{ 93 };
static constexpr short BRIGHT_BLUE{ 94 };
static constexpr short BRIGHT_MAGENTA{ 95 };
static constexpr short BRIGHT_CYAN{ 96 };
static constexpr short BRIGHT_WHITE{ 97 };
//=== Modificators.
static constexpr short REGULAR{ 0 };
static constexpr short BOLD{ 1 };
static constexpr short UNDERLINE{ 4 };
static constexpr short BLINK{ 5 };
static constexpr short REVERSE{ 7 };
inline string tcolor( const string & msg, short color=Color::WHITE, short modifier=Color::REGULAR )
{
ostringstream oss;
oss << "\e[" << modifier << ";" << color << "m" << msg << "\e[0m";
return oss.str();
}
}
#endif
/*!
*
* \file main.cpp
* \author Edson Cassiano
* \date November, 1st
*/
#include <iostream>
#include <fstream>
#include <string>
......@@ -10,17 +17,12 @@ int main(int argc, char *argv[]){
animation.initialize(argc, argv);
// First Scope
// Arquitetura gameloop
// Gerenciador jogo
//
// inicializarJogo(parametros);
//
// while(verdade){
// processar();
// atualizar();
// imprime();
// }
while(not animation.exit()){
animation.process();
animation.update();
animation.render();
}
return 0;
}
This diff is collapsed.
temp.cpp 0 → 100644
#include <iostream>
#include <fstream>
#include <vector>
#include "text_color.h"
int main(){
int a{191825};
return 0;
}
Duvidas:
Se o usuario digitar um comando valido e outro invalido "-b 10 -s a", eu devo considerar o comando valido ou discartar todos os comandos
eDtalhes barchart project
./bcr ../data/arquivo.txt -s <fps> -b <qnt>
-s velocidade
-b quantidade de barras
Tela Welcome
Informações: Se conseguiu acessar o arquivo
Welcome to the bar Chart Race, v1.0
Copyright (C) 2020, Edson Cassiano
>>> Preparing to read input file "../data/arquivo.txt"...
>>> Processing data, please wait.
>>> Input file sucessfuly read.
>>> We have "519" charts, each with 12 bars.
Limite de barras - 12 barras
default 5 barras
Classes
AnimationManeger - faz tudo - cria, ordena, captura printa e joga fora
banco de dados -
barchart - 1 unico grafico
Lib de calcular os frames <thread>
Para a leitura do arquivo siga os seguintes passos:
Eu tenho que ler cada subgrupo linha tamanho do sub grupo
Cada subgrupo tem o campo 0,1,2,3,4
0(Contagem)
1(Titulo da barra)
2(---)
3(Categoria)
No arquivo
Titulo do grafico
Legenda horizontal
Fonte
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment