This commit is contained in:
Estevan BIAU-LOYER 2023-10-02 15:24:37 +02:00
parent ca49bd84aa
commit 241e3111ab
4 changed files with 79 additions and 0 deletions

28
Robot.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <iostream>
#include "Robot.h"
int Robot::getErrorCode() {
return 42;
}
int Robot::getRobotType() {
std::cout << "Robot de fou furieux" << std::endl;
}
int robotique() {
// Create an instance of the Robot class
Robot myRobot;
// Call the moveForward() function
myRobot.getErrorCode();
// Call the turnLeft() function
myRobot.getRobotType();
// Optionally, you can do more with the robot here
return 0;
}

8
Robot.h Normal file
View File

@ -0,0 +1,8 @@
class Robot {
public:
int getErrorCode();
int getRobotType();
};
int robotique();

9
main.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <iostream>
#include "Robot.h"
int main() {
robotique(); // Call the robotique() function
return 0;
}

34
makefile Normal file
View File

@ -0,0 +1,34 @@
# Makefile for compiling and linking your C++ project
# Compiler
CXX = g++
# Compiler flags
CXXFLAGS = -std=c++11 -Wall -Wextra
# Source files (Add your CPP files here)
SRCS = main.cpp Robot.cpp
# Object files
OBJS = $(SRCS:.cpp=.o)
# Executable name
EXEC = my_program
.PHONY: all clean
# Default target
all: $(EXEC)
# Linking
$(EXEC): $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) -o $@
# Compilation
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean up object files and executable
clean:
rm -f $(OBJS) $(EXEC)