From 08584564bd43db857df1e5e17bf9f7be7b451038 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 31 Mar 2022 13:31:37 +0200 Subject: [PATCH] =?UTF-8?q?Ajouts=20-=20R=C3=A9cup=C3=A8re=20des=20informa?= =?UTF-8?q?tions=20via=20CLI,=20avec=20des=20valeurs=20par=20d=C3=A9faut?= =?UTF-8?q?=20le=20cas=20=C3=A9ch=C3=A9ant=20-=20D=C3=A9but=20classe=20Uni?= =?UTF-8?q?vers=20-=20Fonction=20initialisation=20de=20la=20simulation=20-?= =?UTF-8?q?=20Makefile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 20 ++++++++++++++++++++ main.cpp | 35 +++++++++++++++++++++++++++++++++++ univers.cpp | 3 +++ univers.hpp | 11 +++++++++++ 4 files changed, 69 insertions(+) create mode 100644 Makefile create mode 100644 main.cpp create mode 100644 univers.cpp create mode 100644 univers.hpp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f66666c --- /dev/null +++ b/Makefile @@ -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) diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..8f72fa4 --- /dev/null +++ b/main.cpp @@ -0,0 +1,35 @@ +#include +#include + +#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; +} diff --git a/univers.cpp b/univers.cpp new file mode 100644 index 0000000..b5149f9 --- /dev/null +++ b/univers.cpp @@ -0,0 +1,3 @@ +#include "univers.hpp" + +Univers::Univers(int m, int n): _m(m), _n(n) { } diff --git a/univers.hpp b/univers.hpp new file mode 100644 index 0000000..9fc413a --- /dev/null +++ b/univers.hpp @@ -0,0 +1,11 @@ +#ifndef _UNIVERS_HPP_ +#define _UNIVERS_HPP_ 1 + +class Univers { + int _m, _n, _tour; + + public: + Univers(int, int); +}; + +#endif