diff --git a/d02/ex02/Fixed.cpp b/d02/ex02/Fixed.cpp index 3b73c89..3e72ea0 100644 --- a/d02/ex02/Fixed.cpp +++ b/d02/ex02/Fixed.cpp @@ -113,13 +113,13 @@ bool Fixed::operator> (Fixed const & rhs) const { return rhs < *this; } bool Fixed::operator<=(Fixed const & rhs) const { - return !(rhs > *this); + return !(*this > rhs); } bool Fixed::operator>=(Fixed const & rhs) const { - return !(rhs < *this); + return !(*this < rhs); } bool Fixed::operator==(Fixed const & rhs) const { - return this->toFloat() == rhs.toFloat(); + return this->_value == rhs._value; } bool Fixed::operator!=(Fixed const & rhs) const { return !(*this == rhs); @@ -141,8 +141,8 @@ Fixed Fixed::operator* ( Fixed const & rhs ) const { } Fixed Fixed::operator/ ( Fixed const & rhs ) const { Fixed result(*this); - if (rhs.value == 0) - std::cout << "impossible division by 0\n"; + if (rhs._value == 0) + std::cout << "!impossible division by 0ยก"; else result._value = (long)(result._value << Fixed::_frac) / rhs._value; return result; diff --git a/d02/ex02/main.cpp b/d02/ex02/main.cpp index 26c54de..e159ec9 100644 --- a/d02/ex02/main.cpp +++ b/d02/ex02/main.cpp @@ -30,14 +30,14 @@ int main( void ) { // ">" std::cout << "\n" COLOR "operator >"" RESET " RESET "\n"; - std::cout << "e = greater of (c, d) : e == " << (e = (c > d) ? c : d) << '\n'; std::cout << COLOR2 "e:" << e << " c:" << c << " d:" << d << RESET "\n"; + std::cout << "e = greater of (c, d) : e == " << (e = (c > d) ? c : d) << '\n'; std::cout << "e > c ? : " << (e > c) << '\n'; std::cout << "e > d ? : " << (e > d) << '\n'; // "<" std::cout << "\n" COLOR "operator <" RESET "\n"; - std::cout << "e = smaller of (c, d) : e == " << (e = (c < d) ? c : d) << '\n'; std::cout << COLOR2 "e:" << e << " c:" << c << " d:" << d << RESET "\n"; + std::cout << "e = smaller of (c, d) : e == " << (e = (c < d) ? c : d) << '\n'; std::cout << "e < c ? : " << (e < c) << '\n'; std::cout << "e < d ? : " << (e < d) << '\n'; // "<=" @@ -98,6 +98,10 @@ int main( void ) { d = Fixed(10); std::cout << COLOR2 "e:" << e << " c:" << c << " d:" << d << RESET "\n"; std::cout << "e = c / d ? : " << (e = c / d) << '\n'; + c = Fixed(6); + d = Fixed(0); + std::cout << COLOR2 "e:" << e << " c:" << c << " d:" << d << RESET "\n"; + std::cout << "e = c / d ? : " << (e = c / d) << '\n'; // "+ - * /" std::cout << "\n" COLOR "operator + - * /" RESET "\n"; Fixed g; @@ -111,22 +115,18 @@ int main( void ) { // "++x" std::cout << "\n" COLOR "operator ++o" RESET "\n"; e = Fixed(2); - std::cout << "e : " << e << '\n'; std::cout << COLOR2 "e:" << e << RESET "\n"; std::cout << "++e : " << ++e << " ; e : " << e << '\n'; // "--x" std::cout << "\n" COLOR "operator --o" RESET "\n"; - std::cout << "e : " << e << '\n'; std::cout << COLOR2 "e:" << e << RESET "\n"; std::cout << "--e : " << --e << " ; e : " << e << '\n'; // "x++" std::cout << "\n" COLOR "operator o++" RESET "\n"; - std::cout << "e : " << e << '\n'; std::cout << COLOR2 "e:" << e << RESET "\n"; std::cout << "e++ : " << e++ << " ; e : " << e << '\n'; // "x--" std::cout << "\n" COLOR "operator o--" RESET "\n"; - std::cout << "e : " << e << '\n'; std::cout << COLOR2 "e:" << e << RESET "\n"; std::cout << "e-- : " << e-- << " ; e : " << e << '\n'; diff --git a/d02/ex02/operators b/d02/ex02/operators index 0d59a29..fc8998f 100755 Binary files a/d02/ex02/operators and b/d02/ex02/operators differ diff --git a/d03/ex01/ScavTrap.cpp b/d03/ex01/ScavTrap.cpp index fb21426..242fafd 100644 --- a/d03/ex01/ScavTrap.cpp +++ b/d03/ex01/ScavTrap.cpp @@ -7,7 +7,7 @@ ScavTrap::ScavTrap( std::string name ) : ClapTrap(name) { _energy = 50; _attack = 20; - std::cout << _class << " " << _name << " created with number " << _number << "\n"; + std::cout << _class << " " << ScavTrap::_name << " created with number " << _number << "\n"; return; } @@ -17,6 +17,14 @@ ScavTrap::ScavTrap( std::string name ) : ClapTrap(name) { */ ScavTrap::~ScavTrap( void ) { - std::cout << _class << " " << _name << " destructed\n"; + std::cout << _class << " " << ScavTrap::_name << " destructed\n"; return; } + +/* + * special capacity + */ + +void ScavTrap::guardGate() { + std::cout << _class << " entered special mode Gate Keeper\n"; +} diff --git a/d03/ex01/ScavTrap.hpp b/d03/ex01/ScavTrap.hpp index e6fb39e..9618d2b 100644 --- a/d03/ex01/ScavTrap.hpp +++ b/d03/ex01/ScavTrap.hpp @@ -12,6 +12,8 @@ public: ScavTrap(std::string name); ~ScavTrap(); + void guardGate(); + }; #endif diff --git a/d03/ex01/robots b/d03/ex01/robots index 6e5d271..5626fc9 100755 Binary files a/d03/ex01/robots and b/d03/ex01/robots differ