Deuxieme commit

This commit is contained in:
YANNIS
2025-05-29 16:53:26 +02:00
parent 33c6f3ccff
commit bd9bc5e2e2
5 changed files with 14 additions and 14 deletions
-2
View File
@@ -10,11 +10,9 @@ class Bomb {
bool _active; bool _active;
public: public:
Bomb(): _position({0, 0}), _timer(3), _active(false) { 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) { Bomb(Position position) : _position(position), _timer(3), _active(false) {
std::cout << "Bomb created at " << position << std::endl;
} }
void activate() { _active = true; } void activate() { _active = true; }
-7
View File
@@ -1,10 +1,3 @@
//Bomberman.cpp //Bomberman.cpp
#include "Bomberman.hpp" #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;
}
+7 -2
View File
@@ -7,10 +7,15 @@ class Bomberman {
private: private:
Position _position; Position _position;
unsigned short _numberOfBombs; unsigned short _maxNumberOfBombs = 1;
unsigned short _numberOfBombsPlanted = 0;
Bomb _bomb; Bomb _bomb;
public: public:
Bomberman(){std::cout << "Bomberman created!" << std::endl;} Bomberman(){std::cout << "Bomberman created!" << std::endl;}
Bomberman(const Position &position, unsigned short numberOfBombs);
~Bomberman(){std::cout << "Bomberman destroyed!" << std::endl;}; ~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;
}
}; };
+5 -3
View File
@@ -8,13 +8,15 @@ SRC = main.cpp \
OBJ = $(SRC:.cpp=.o) OBJ = $(SRC:.cpp=.o)
all: $(NAME)
$(NAME): $(OBJ) $(NAME): $(OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(CC) $(CFLAGS) -o $@ $(OBJ)
$(OBJ): $(SRC) $(OBJ): $(SRC)
$(CC) $(CFLAGS) -c $(SRC) -o $@ $(CC) $(CFLAGS) -c $(SRC)
all: $(NAME)
clean: clean:
rm -f $(OBJ) rm -f $(OBJ)
fclean: clean fclean: clean
+2
View File
@@ -1,6 +1,8 @@
#include "Bomberman.hpp" #include "Bomberman.hpp"
#include <iostream>
int main (void){ int main (void){
Bomberman bomberman; Bomberman bomberman;
std::cout << bomberman << std::endl;
return 0; return 0;
} }