Skip to content
Snippets Groups Projects
Commit 6b9aaea4 authored by speedson's avatar speedson
Browse files

first changes

parent 3b507c54
No related branches found
No related tags found
No related merge requests found
Makefile 0 → 100644
# Makefile Bar Chart Race
# Project Name
PROJ_NAME = bcr
# Sources files (*.cpp)
CPP_SOURCE = $(wildcard ./src/*.cpp)
# Header files (*.h)
H_SOURCE = $(wildcard ./lib/*h)
# Objects files
OBJ_FILE = $(subst .cpp,.o, $(subst src,bin,$(CPP_SOURCE)))
# Compiler
CC = g++
# Flags for Compiler
CC_FLAGS = -c \
-Wall \
-std=c++11
# Remove Command
RM = rm -rf
# Commands
all: objFolder $(PROJ_NAME)
$(PROJ_NAME): $(OBJ_FILE) ./bin/main.o
@ echo 'Building executable file: $@. Compiler: $(CC)'
$(CC) -o $@ $^
@ echo ' '
@ echo 'To run the program use ./$(PROJ_NAME)'
./bin/%.o: ./src/%.cpp ./lib/%.h
@ echo 'Building $<. Compiler $(CC)'
$(CC) $< $(CC_FLAGS) -o $@
@ echo ' '
./bin/main.o: main.cpp $(OBJ_FILE)
@ echo 'Building $<. Compiler: $(CC)'
$(CC) $< $(CC_FLAGS) -o $@
@ echo ' '
objFolder:
@ mkdir -p bin
clean:
@ $(RM) ./bin/*
@ rmdir bin
bcr 0 → 100755
File added
bin/bcr.o 0 → 100644
File added
File added
teste0
teste1
teste2
teste3
teste4
teste5
teste6
teste7
teste8
teste9
#ifndef BCR_H
#define BCR_H
class AnimationManage{
private:
int m_frameRate;
int m_numberOfBar;
std::string m_fileName;
public:
AnimationManage(int frameRate=24, int numberOfBar=5);
void setAnimationManage(int frameRate, int numberOfBar);
void setFrame(int frameRate);
void setNumberOfBar(int numberOfBar);
void setFileName(std::string fileName);
int getFrame(){ return m_frameRate; }
int getnumberOfBar(){ return m_numberOfBar; }
std::string getFileName(){ return m_fileName; }
//Nessa função eu preciso abrir o arquivo apartir da linha de commando, tratando os erros
//erros: arquivo nao encontrado, parametros invalidos
void initialize(int argc, char *argv[]);
};
void teste();
#endif
#include <iostream>
#include <fstream>
#include <string>
#include "lib/bcr.h"
int main(int argc, char *argv[]){
AnimationManage animation;
std::ifstream file(argv[1]);
std::string st;
animation.initialize(argc, argv);
if(file.is_open()){
while(!file.eof()){
file >> st;
std::cout << st << std::endl;
}
}
// First Scope
// Arquitetura gameloop
// Gerenciador jogo
......
#include <iostream>
#include <string>
#include "../lib/bcr.h"
void teste(){ std::cout << "TESTE" << std::endl; }
//Construct
AnimationManage::AnimationManage(int frameRate, int numberOfBar){
setAnimationManage(frameRate, numberOfBar);
}
//start sets
void AnimationManage::setAnimationManage(int frameRate, int numberOfBar){
m_frameRate = frameRate;
m_numberOfBar = numberOfBar;
}
void AnimationManage::setFrame(int frameRate){
m_frameRate = frameRate;
}
void AnimationManage::setNumberOfBar(int numberOfBar){
m_numberOfBar = numberOfBar;
}
void AnimationManage::setFileName(std::string fileName){
m_fileName = fileName;
}
//end sets
void AnimationManage::initialize(int argc, char *argv[]){
std::string firstArgument;
std::string secondArgument;
std::cout << "argc: " << argc << std::endl;
if(argc == 1){// Caso o user nao passe argumentos retornar erro
std::cout << "Sem parametros validos" << std::endl;
}else if(argc == 2){//Caso o user passe apenas o nome do arquivo: carregar valores padroes
setFileName(argv[1]);
std::cout << "file: " << getFileName() << std::endl;
}else if(argc == 3){//parametros digitados mas invalidos
std::cout << "Faltam parametros" << std::endl;
}
else if(argc == 4){//Caso o user digite apenas um parametro
firstArgument = argv[2];
if(firstArgument.compare("-b") == 0){//Check se o user quer mudar a qnt de barras
std::cout << "Bars Command Valid" << std::endl;
//TODO Checkar se argumento 3(argv[3]) é um inteiro
}else if(firstArgument.compare("-s") == 0){//Check se o user quer mudar a quantidade de frames
std::cout << "Frames Command Valid" << std::endl;
//TODO Checkar se argumento 3(argv[3]) é um inteiro
}else{//Se o user Digitar algum comando invalido
std::cout << "Invalid Command" << std::endl;
}
}else if(argc == 5){//Segundo parametro invalido
std::cout << "Segundo parametro invalido" << std::endl;
}else if(argc == 6){//tamanho esperado
firstArgument = argv[2];
secondArgument = argv[4];
//Check se Ambos argumentos sao validos
if(firstArgument.compare("-b") == 0 || firstArgument.compare("-s") == 0){
if(secondArgument.compare(firstArgument) != 0){//Check se os args sao diferentes
if(secondArgument.compare("-b") == 0){
std::cout << "primeiro arg: -s segundo arg: -b " << std::endl;
}else if(secondArgument.compare("-s") == 0){
std::cout << "primeiro arg: -b segundo arg: -s " << std::endl;
}else{
std::cout << "Comandos Invalidos" << std::endl;
}
}else{
std::cout << "Mesmo comandos" << std::endl;
}
}else{//Check se os comandos sao invalidos(cmds inexistentes ou errados)
std::cout << "Comandos invalidos" << std::endl;
}
}
}
ttt.txt 0 → 100644
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)
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