Ajouts
- Récupère des informations via CLI, avec des valeurs par défaut le cas échéant - Début classe Univers - Fonction initialisation de la simulation - Makefile
This commit is contained in:
parent
853f3a820b
commit
08584564bd
4 changed files with 69 additions and 0 deletions
20
Makefile
Normal file
20
Makefile
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
CCPP = g++
|
||||||
|
CFLAGS = -I. -Wall -Wextra -fanalyzer --std=c++17
|
||||||
|
CFLAGS2 = -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter
|
||||||
|
|
||||||
|
SOURCES = $(shell find . -name '*.cpp')
|
||||||
|
OBJECTS = $(SOURCES:.cpp=.o)
|
||||||
|
|
||||||
|
NOM = ecosyteme
|
||||||
|
|
||||||
|
%.o: %.cpp
|
||||||
|
$(CCPP) -c -o $@ $< $(CFLAGS) $(CFLAGS2)
|
||||||
|
|
||||||
|
main: $(OBJECTS)
|
||||||
|
$(CCPP) -o $(NOM) $^ $(CFLAGS) $(CFLAGS2)
|
||||||
|
|
||||||
|
all:
|
||||||
|
main
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm *.o $(NOM)
|
35
main.cpp
Normal file
35
main.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "univers.hpp"
|
||||||
|
|
||||||
|
void lancerSimulation(int m, int n, int nb_moutons, int nb_loups) {
|
||||||
|
Univers univers(m, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* m x n = taille de l'univers
|
||||||
|
* nb_moutons = nombre de moutons
|
||||||
|
* nb_loups = nombre de loups */
|
||||||
|
int main(int argc, char const *argv[]) {
|
||||||
|
if(argc > 1 && argc != 5) {
|
||||||
|
std::cerr << "Arguments non renseignés." << std::endl;
|
||||||
|
std::cout << "Usage : " << argv[0] << " m n nb_moutons nb_loups" << std::endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
int m, n, nb_moutons, nb_loups;
|
||||||
|
if(argc == 5) { // renseigné par l'utilisateur
|
||||||
|
m = std::stoi(argv[1]);
|
||||||
|
n = std::stoi(argv[2]);
|
||||||
|
nb_moutons = std::stoi(argv[3]);
|
||||||
|
nb_loups = std::stoi(argv[4]);
|
||||||
|
} else { // valeurs par défaut
|
||||||
|
m = 5;
|
||||||
|
n = 5;
|
||||||
|
nb_moutons = 7;
|
||||||
|
nb_loups = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
lancerSimulation(m, n, nb_moutons, nb_loups);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
3
univers.cpp
Normal file
3
univers.cpp
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#include "univers.hpp"
|
||||||
|
|
||||||
|
Univers::Univers(int m, int n): _m(m), _n(n) { }
|
11
univers.hpp
Normal file
11
univers.hpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef _UNIVERS_HPP_
|
||||||
|
#define _UNIVERS_HPP_ 1
|
||||||
|
|
||||||
|
class Univers {
|
||||||
|
int _m, _n, _tour;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Univers(int, int);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Reference in a new issue