This commit is contained in:
Alexandre POMMIER 2022-07-23 16:26:15 +02:00
parent 8543b33348
commit 4d9723ab8a
12 changed files with 197 additions and 71 deletions

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/10 21:20:34 by apommier #+# #+# */
/* Updated: 2022/06/19 12:36:43 by apommier ### ########.fr */
/* Updated: 2022/07/23 12:37:20 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,7 +19,6 @@ HumanA::HumanA(const std::string name, Weapon &Weapon): _Weapon(Weapon)
HumanA::~HumanA(void)
{
}
void HumanA::attack(void)

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/10 21:13:13 by apommier #+# #+# */
/* Updated: 2022/06/19 15:54:48 by apommier ### ########.fr */
/* Updated: 2022/07/23 12:37:01 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,24 +23,12 @@ Weapon::Weapon(std::string type) : _type(type){
Weapon::~Weapon() {
return;
}
/*Weapon::Weapon(std::string name): _type(name) {
}
Weapon::~Weapon() {
}*/
const std::string& Weapon::getType(void) const
{
return (this->_type);
}
/*void Weapon::setType(const std::string type)
{
this->_type = type;
}*/
void Weapon::setType(std::string newType) {
_type = newType;
}

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/10 19:43:13 by apommier #+# #+# */
/* Updated: 2022/06/19 15:55:10 by apommier ### ########.fr */
/* Updated: 2022/07/23 12:36:35 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,7 +25,6 @@ class Weapon {
Weapon(std::string type);
~Weapon();
const std::string& getType( void ) const;
//void setType(const std::string type);
void setType(std::string newType);
private:

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/10 20:12:10 by apommier #+# #+# */
/* Updated: 2022/06/16 22:57:13 by apommier ### ########.fr */
/* Updated: 2022/07/23 12:42:17 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
@ -30,5 +30,15 @@ int main()
club.setType("some other type of club");
jim.attack();
}
return 0;
{
Weapon club = Weapon("crude spiked club");
HumanB jim("Jim");
jim.setWeapon(club);
HumanB john(jim);
john.attack();
club.setType("some other type of club");
john.attack();
}
return (0);
}

View File

@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Form.cpp :+: :+: :+: */
/* AForm.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@ -10,9 +10,9 @@
/* */
/* ************************************************************************** */
#include "Form.hpp"
#include "AForm.hpp"
Form::Form(int signedGrade, int executionGrade, std::string name) : _name(name)
AForm::AForm(int signedGrade, int executionGrade, std::string name) : _name(name)
{
this->_signedGrade = signedGrade;
this->_executionGrade = executionGrade;
@ -20,17 +20,17 @@ Form::Form(int signedGrade, int executionGrade, std::string name) : _name(name)
this->checkGrade();
}
Form::Form(const Form& copy)
AForm::AForm(const AForm& copy)
{
*this = copy;
}
Form::~Form()
AForm::~AForm()
{
}
Form &Form::operator=(const Form& rhs)
AForm &AForm::operator=(const AForm& rhs)
{
if (this != &rhs)
{
@ -41,54 +41,54 @@ Form &Form::operator=(const Form& rhs)
return (*this);
}
std::ostream &operator<<(std::ostream &out, const Form &form)
std::ostream &operator<<(std::ostream &out, const AForm &Aform)
{
out << form.getName() << "form need at least " << form.getSignedGrade() << " grade to be signed and ";
out << form.getExecutionGrade() << " grade to be executed, ";
if (form.getIsSigned())
out << form.getName() << " form is signed\n";
out << Aform.getName() << "Aform need at least " << Aform.getSignedGrade() << " grade to be signed and ";
out << Aform.getExecutionGrade() << " grade to be executed, ";
if (Aform.getIsSigned())
out << Aform.getName() << " Aform is signed\n";
else
out << form.getName() << " form isn't signed\n";
out << Aform.getName() << " Aform isn't signed\n";
return (out);
}
int Form::getSignedGrade() const
int AForm::getSignedGrade() const
{
return (this->_signedGrade);
}
int Form::getExecutionGrade() const
int AForm::getExecutionGrade() const
{
return (this->_executionGrade);
}
int Form::getIsSigned() const
int AForm::getIsSigned() const
{
return (this->_isSigned);
}
const std::string Form::getName() const
const std::string AForm::getName() const
{
return (this->_name);
}
void Form::beSigned(Bureaucrat &bureaucrat)
void AForm::beSigned(Bureaucrat &bureaucrat)
{
if (bureaucrat.getGrade() > this->_signedGrade)
throw Form::signedGradeTooLowException();
throw AForm::signedGradeTooLowException();
else
{
this->_isSigned = 1;
std::cout << bureaucrat.getName() << " signed " << this->_name << " form\n";
std::cout << bureaucrat.getName() << " signed " << this->_name << " Aform\n";
}
}
void Form::checkGrade() const
void AForm::checkGrade() const
{
if (this->_signedGrade > 150 || this->_executionGrade > 150)
throw Form::GradeTooLowException();
throw AForm::GradeTooLowException();
else if (this->_signedGrade < 1 || this->_executionGrade < 1)
throw Form::GradeTooHighException();
throw AForm::GradeTooHighException();
}

View File

@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Form.hpp :+: :+: :+: */
/* AForm.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@ -10,8 +10,8 @@
/* */
/* ************************************************************************** */
#ifndef FORM_HPP
# define FORM_HPP
#ifndef AFORM_HPP
# define AFORM_HPP
# include <ostream>
# include <string>
@ -20,20 +20,20 @@
class Bureaucrat;
class Form{
class AForm{
public :
Form(int signedGrade, int executionGrade, std::string name);
Form(const Form& copy);
~Form();
Form &operator=(const Form& rhs);
AForm(int signedGrade, int executionGrade, std::string name);
AForm(const AForm& copy);
~AForm();
AForm &operator=(const AForm& rhs);
const std::string getName() const;
int getSignedGrade() const;
int getExecutionGrade() const;
int getIsSigned() const;
void checkGrade() const;
void checkGrade() const = 0;
void beSigned(Bureaucrat &bureaucrat);
@ -72,6 +72,6 @@ class Form{
int _executionGrade;
};
std::ostream &operator<<(std::ostream &out, const Form &form);
std::ostream &operator<<(std::ostream &out, const AForm &Aform);
#endif

View File

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* PresidentialPardonForm.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/23 12:16:26 by apommier #+# #+# */
/* Updated: 2022/07/23 12:35:33 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "PresidentialPardonForm.cpp"
PresidentialPardonForm()
{
}
PresidentialPardonForm(const PresidentialPardonForm& copy)
{
}
~PresidentialPardonForm()
{
}
PresidentialPardonForm &operator=(const PresidentialPardonForm& rhs)
{
}

View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* PresidentialPardonForm.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/23 12:16:28 by apommier #+# #+# */
/* Updated: 2022/07/23 13:43:32 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PRESIDENTIALPARDONFORM_HPP
# define PRESIDENTIALPARDONFORM_HPP
# include "AForm.hpp"
class PresidentialPardonForm : public AForm{
public :
PresidentialPardonForm();
PresidentialPardonForm(const PresidentialPardonForm& copy);
~PresidentialPardonForm();
PresidentialPardonForm &operator=(const PresidentialPardonForm& rhs);
private :
};
#endif

View File

@ -6,12 +6,28 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/19 13:00:09 by apommier #+# #+# */
/* Updated: 2022/07/19 22:01:30 by apommier ### ########.fr */
/* Updated: 2022/07/23 12:35:53 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
class RobotomyRequestForm{
public :
#include "RobotomyRequestForm.hpp"
private :
};
RobotomyRequestForm()
{
}
RobotomyRequestForm(const RobotomyRequestForm.hpp& copy)
{
}
~RobotomyRequestForm()
{
}
RobotomyRequestForm.hpp &operator=(const RobotomyRequestForm.hpp& rhs)
{
}

View File

@ -1,12 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* RobotomyRequestForm.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/19 13:00:11 by apommier #+# #+# */
/* Updated: 2022/07/19 13:00:12 by apommier ### ########.fr */
/* */
/* */
/* ::: :::::::: */
/* RobotomyRequestForm.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/19 13:00:11 by apommier #+# #+# */
/* Updated: 2022/07/23 12:30:09 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ROBOTOMYREQUESTFORM_HPP
# define ROBOTOMYREQUESTFORM_HPP
# include "AForm.hpp"
class RobotomyRequestForm : public AForm{
public :
RobotomyRequestForm();
RobotomyRequestForm(const RobotomyRequestForm& copy);
~RobotomyRequestForm();
RobotomyRequestForm &operator=(const RobotomyRequestForm& rhs);
private :
};
#endif

View File

@ -6,15 +6,33 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/19 13:00:14 by apommier #+# #+# */
/* Updated: 2022/07/19 22:24:06 by apommier ### ########.fr */
/* Updated: 2022/07/23 12:35:04 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
class ShrubberyCreationForm{
public :
#include "ShrubberyCreationForm.hpp"
ShrubberyCreationForm()
{
}
ShrubberyCreationForm(const ShrubberyCreationForm& copy)
{
}
~ShrubberyCreationForm()
{
}
ShrubberyCreationForm &operator=(const ShrubberyCreationForm& rhs)
{
}
private :
};
// _
// /;-._,-.____ ,-----.__

View File

@ -6,7 +6,24 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/19 13:00:12 by apommier #+# #+# */
/* Updated: 2022/07/19 13:00:14 by apommier ### ########.fr */
/* Updated: 2022/07/23 13:43:44 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SHRUBBERYCREATIONFORM_HPP
# define SHRUBBERYCREATIONFORM_HPP
# include "AForm.hpp"
class ShrubberyCreationForm : public AForm{
public :
ShrubberyCreationForm();
ShrubberyCreationForm(const ShrubberyCreationForm& copy);
~ShrubberyCreationForm();
ShrubberyCreationForm &operator=(const ShrubberyCreationForm& rhs);
private :
};
#endif