d07 ajouts tests avec fixed et char dans ex01 et ex02
This commit is contained in:
55
d07/ex00/headers/Fixed.hpp
Normal file
55
d07/ex00/headers/Fixed.hpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifndef FIXED_HPP
|
||||
# define FIXED_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
class Fixed {
|
||||
|
||||
public:
|
||||
|
||||
Fixed(void); // default/parametric constructor
|
||||
Fixed(Fixed const & src); // copy constructor
|
||||
~Fixed(void); // destructor
|
||||
Fixed(int integer);
|
||||
Fixed(float const floater);
|
||||
|
||||
Fixed & operator= (Fixed const & rhs); // assignement operator
|
||||
bool operator< (Fixed const & rhs) const;
|
||||
bool operator> (Fixed const & rhs) const;
|
||||
bool operator<=(Fixed const & rhs) const;
|
||||
bool operator>=(Fixed const & rhs) const;
|
||||
bool operator==(Fixed const & rhs) const;
|
||||
bool operator!=(Fixed const & rhs) const;
|
||||
Fixed operator+ (Fixed const & rhs) const;
|
||||
Fixed operator- (Fixed const & rhs) const;
|
||||
Fixed operator* (Fixed const & rhs) const;
|
||||
Fixed operator/ (Fixed const & rhs) const;
|
||||
Fixed & operator++(void); // prefix ++o
|
||||
Fixed & operator--(void); // prefix --o
|
||||
Fixed operator++(int); // postfix o++
|
||||
Fixed operator--(int); // postfix o--
|
||||
|
||||
static const Fixed & min(Fixed const & lhs, Fixed const & rhs);
|
||||
static const Fixed & max(Fixed const & lhs, Fixed const & rhs);
|
||||
static Fixed & min(Fixed & lhs, Fixed & rhs);
|
||||
static Fixed & max(Fixed & lhs, Fixed & rhs);
|
||||
|
||||
int getRawBits(void) const;
|
||||
void setRawBits(int const raw);
|
||||
float toFloat(void) const;
|
||||
int toInt(void) const;
|
||||
|
||||
private:
|
||||
|
||||
int _value;
|
||||
static int const _frac;
|
||||
static int const _max;
|
||||
static int const _min;
|
||||
|
||||
};
|
||||
|
||||
std::ostream & operator<<(std::ostream & o, Fixed const & rhs);
|
||||
|
||||
#endif
|
||||
28
d07/ex00/headers/Templates.hpp
Normal file
28
d07/ex00/headers/Templates.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef TEMPLATES_HPP
|
||||
# define TEMPLATES_HPP
|
||||
|
||||
template< typename T >
|
||||
void swap(T &a, T &b) {
|
||||
|
||||
T tmp;
|
||||
|
||||
tmp = a;
|
||||
a = b;
|
||||
b = tmp;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T const & min(T const &a, T const &b) {
|
||||
if (a < b)
|
||||
return a;
|
||||
return b;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T const & max(T const &a, T const &b) {
|
||||
if (a > b)
|
||||
return a;
|
||||
return b;
|
||||
}
|
||||
|
||||
#endif
|
||||
25
d07/ex00/headers/colors.h
Normal file
25
d07/ex00/headers/colors.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef COLORS_H
|
||||
# define COLORS_H
|
||||
|
||||
# define GRAY "\e[0;30m"
|
||||
# define RED "\e[0;31m"
|
||||
# define GREEN "\e[0;32m"
|
||||
# define YELLOW "\e[0;33m"
|
||||
# define BLUE "\e[0;34m"
|
||||
# define PURPLE "\e[0;35m"
|
||||
# define CYAN "\e[0;36m"
|
||||
# define WHITE "\e[0;37m"
|
||||
|
||||
# define B_GRAY "\e[1;30m"
|
||||
# define B_RED "\e[1;31m"
|
||||
# define B_GREEN "\e[1;32m"
|
||||
# define B_YELLOW "\e[1;33m"
|
||||
# define B_BLUE "\e[1;34m"
|
||||
# define B_PURPLE "\e[1;35m"
|
||||
# define B_CYAN "\e[1;36m"
|
||||
# define B_WHITE "\e[1;37m"
|
||||
|
||||
# define RESET "\e[0m"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user