From bd9bc5e2e2058a6d1a0b226c5e388ef3e0b7e4b6 Mon Sep 17 00:00:00 2001 From: YANNIS Date: Thu, 29 May 2025 16:53:26 +0200 Subject: [PATCH] Deuxieme commit --- Bomb.hpp | 2 -- Bomberman.cpp | 7 ------- Bomberman.hpp | 9 +++++++-- Makefile | 8 +++++--- main.cpp | 2 ++ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Bomb.hpp b/Bomb.hpp index 401a532..36becd1 100644 --- a/Bomb.hpp +++ b/Bomb.hpp @@ -10,11 +10,9 @@ class Bomb { bool _active; public: Bomb(): _position({0, 0}), _timer(3), _active(false) { - std::cout << "Bomb created at default position " << std::endl; }; Bomb(Position position) : _position(position), _timer(3), _active(false) { - std::cout << "Bomb created at " << position << std::endl; } void activate() { _active = true; } diff --git a/Bomberman.cpp b/Bomberman.cpp index f9b11e0..51a84ac 100644 --- a/Bomberman.cpp +++ b/Bomberman.cpp @@ -1,10 +1,3 @@ //Bomberman.cpp #include "Bomberman.hpp" -Bomberman::Bomberman(const Position &position, unsigned short numberOfBombs) - : _position(position), _numberOfBombs(numberOfBombs) { - std::cout << "Bomberman created at position (" - << _position.getX() << ", " << _position.getY() - << ") with " << _numberOfBombs - << " bombs!" << std::endl; -} diff --git a/Bomberman.hpp b/Bomberman.hpp index a09867a..8aefa58 100644 --- a/Bomberman.hpp +++ b/Bomberman.hpp @@ -7,10 +7,15 @@ class Bomberman { private: Position _position; - unsigned short _numberOfBombs; + unsigned short _maxNumberOfBombs = 1; + unsigned short _numberOfBombsPlanted = 0; Bomb _bomb; public: Bomberman(){std::cout << "Bomberman created!" << std::endl;} - Bomberman(const Position &position, unsigned short numberOfBombs); ~Bomberman(){std::cout << "Bomberman destroyed!" << std::endl;}; + int plantBomb(); + friend std::ostream& operator<<(std::ostream &os, const Bomberman &bomberman) { + os << "Bomberman at " << bomberman._position << ", Number of bombs: " << bomberman._numberOfBombs; + return os; + } }; diff --git a/Makefile b/Makefile index 1bf3678..99bc61e 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,15 @@ SRC = main.cpp \ OBJ = $(SRC:.cpp=.o) -all: $(NAME) $(NAME): $(OBJ) - $(CC) $(CFLAGS) -o $@ $^ + $(CC) $(CFLAGS) -o $@ $(OBJ) $(OBJ): $(SRC) - $(CC) $(CFLAGS) -c $(SRC) -o $@ + $(CC) $(CFLAGS) -c $(SRC) + +all: $(NAME) + clean: rm -f $(OBJ) fclean: clean diff --git a/main.cpp b/main.cpp index 83685bc..a658139 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,8 @@ #include "Bomberman.hpp" +#include int main (void){ Bomberman bomberman; + std::cout << bomberman << std::endl; return 0; }