From 18ca1fc67ccc7bf176287f7b2908a33a597ec67a Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Tue, 10 Nov 2020 12:01:44 +0100 Subject: Added more tests for cpp02/02 --- cpp02/ex01/Fixed.cpp | 2 +- cpp02/ex01/Fixed.hpp | 10 ++++------ cpp02/ex01/main.cpp | 35 ---------------------------------- cpp02/ex01/main_DO_NOT_TURN_ME_IN.cpp | 36 +++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 42 deletions(-) delete mode 100644 cpp02/ex01/main.cpp create mode 100644 cpp02/ex01/main_DO_NOT_TURN_ME_IN.cpp (limited to 'cpp02/ex01') diff --git a/cpp02/ex01/Fixed.cpp b/cpp02/ex01/Fixed.cpp index 14ba1c6..759807b 100644 --- a/cpp02/ex01/Fixed.cpp +++ b/cpp02/ex01/Fixed.cpp @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/13 11:45:18 by charles #+# #+# */ -/* Updated: 2020/11/09 13:11:29 by cacharle ### ########.fr */ +/* Updated: 2020/11/10 09:59:45 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/cpp02/ex01/Fixed.hpp b/cpp02/ex01/Fixed.hpp index 1f768f6..43edba2 100644 --- a/cpp02/ex01/Fixed.hpp +++ b/cpp02/ex01/Fixed.hpp @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/13 11:40:49 by charles #+# #+# */ -/* Updated: 2020/11/09 13:11:15 by cacharle ### ########.fr */ +/* Updated: 2020/11/10 10:02:06 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,13 +27,11 @@ public: Fixed(const int from); Fixed(const float from); - int getRawBits() const; - void setRawBits(int const raw); - int getRawBits() const; void setRawBits(int const raw); - float toFloat() const; - int toInt() const; + + float toFloat(void) const; // void asked by subject + int toInt(void) const; static int getFractionalBits(); diff --git a/cpp02/ex01/main.cpp b/cpp02/ex01/main.cpp deleted file mode 100644 index 34d365a..0000000 --- a/cpp02/ex01/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* main.cpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: charles +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/04/13 11:51:15 by charles #+# #+# */ -/* Updated: 2020/10/19 11:28:50 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include -#include "Fixed.hpp" - -int main(void) -{ - Fixed a; - Fixed const b(10); - Fixed const c(42.42f); - Fixed const d(b); - - a = Fixed(1234.4321f); - std::cout << "a is " << a << std::endl; - std::cout << "b is " << b << std::endl; - std::cout << "c is " << c << std::endl; - std::cout << "d is " << d << std::endl; - - std::cout << "a is " << a.toInt() << " as integer" << std::endl; - std::cout << "b is " << b.toInt() << " as integer" << std::endl; - std::cout << "c is " << c.toInt() << " as integer" << std::endl; - std::cout << "d is " << d.toInt() << " as integer" << std::endl; - - return 0; -} diff --git a/cpp02/ex01/main_DO_NOT_TURN_ME_IN.cpp b/cpp02/ex01/main_DO_NOT_TURN_ME_IN.cpp new file mode 100644 index 0000000..f2eb5e0 --- /dev/null +++ b/cpp02/ex01/main_DO_NOT_TURN_ME_IN.cpp @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main_DO_NOT_TURN_ME_IN.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/13 11:51:15 by charles #+# #+# */ +/* Updated: 2020/11/10 10:00:32 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include "Fixed.hpp" + +int main(void) +{ + Fixed a; + Fixed const b(10); + Fixed const c(42.42f); + Fixed const d(b); + + a = Fixed(1234.4321f); + + std::cout << "a is " << a << std::endl; + std::cout << "b is " << b << std::endl; + std::cout << "c is " << c << std::endl; + std::cout << "d is " << d << std::endl; + + std::cout << "a is " << a.toInt() << " as integer" << std::endl; + std::cout << "b is " << b.toInt() << " as integer" << std::endl; + std::cout << "c is " << c.toInt() << " as integer" << std::endl; + std::cout << "d is " << d.toInt() << " as integer" << std::endl; + + return 0; +} -- cgit