diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-04-13 10:33:05 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-04-13 10:33:05 +0200 |
| commit | 0f3240844dbd5a874e1565a988ef355ededab6a5 (patch) | |
| tree | efc1a1307863d173be17a12fbab6b84fe7d00960 /cpp01/ex00 | |
| parent | 629d52b1262879a346e9ca17567a8f483c60ba0a (diff) | |
| download | piscine_cpp-0f3240844dbd5a874e1565a988ef355ededab6a5.tar.gz piscine_cpp-0f3240844dbd5a874e1565a988ef355ededab6a5.tar.bz2 piscine_cpp-0f3240844dbd5a874e1565a988ef355ededab6a5.zip | |
Fixing cpp01
Diffstat (limited to 'cpp01/ex00')
| -rw-r--r-- | cpp01/ex00/Pony.cpp | 19 | ||||
| -rw-r--r-- | cpp01/ex00/Pony.hpp | 26 | ||||
| -rw-r--r-- | cpp01/ex00/main.cpp | 16 |
3 files changed, 43 insertions, 18 deletions
diff --git a/cpp01/ex00/Pony.cpp b/cpp01/ex00/Pony.cpp index 61f3b47..b45f0e1 100644 --- a/cpp01/ex00/Pony.cpp +++ b/cpp01/ex00/Pony.cpp @@ -6,27 +6,28 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/13 09:06:06 by charles #+# #+# */ -/* Updated: 2020/04/13 09:06:11 by charles ### ########.fr */ +/* Updated: 2020/04/13 09:33:59 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include <iostream> #include "Pony.hpp" -Pony::Pony(int w, int s) +Pony::Pony(int weight, int maxSpeed) + : m_weight(weight), m_maxSpeed(maxSpeed) { - weight = w; - max_speed = s; } -void Pony::say_hello() +void Pony::sayHello() { - std::cout << "Hi, I'm a pony, I weight " << weight - << " and my speed limit is " << max_speed << std::endl; + std::cout << "Hi, I'm a pony, I weight " << m_weight + << " and my speed limit is " << m_maxSpeed + << std::endl; } void Pony::run() { - for (int i = 0; i < max_speed; i++) - std::cout << "I'm running really fast at " << i << ", look at me!" << std::endl; + for (int i = 0; i <= m_maxSpeed; i += m_maxSpeed / 10) + std::cout << "I'm running really fast at " << i + << ", look at me!" << std::endl; } diff --git a/cpp01/ex00/Pony.hpp b/cpp01/ex00/Pony.hpp index 31a69f4..571414c 100644 --- a/cpp01/ex00/Pony.hpp +++ b/cpp01/ex00/Pony.hpp @@ -1,15 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Pony.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/13 09:26:16 by charles #+# #+# */ +/* Updated: 2020/04/13 09:27:49 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef PONY_HPP # define PONY_HPP class Pony { - public: - Pony(int w, int s); - void say_hello(); - void run(); - private: - int weight; - int max_speed; +public: + Pony(int weight, int maxSpeed); + void sayHello(); + void run(); +private: + int m_weight; + int m_maxSpeed; }; #endif diff --git a/cpp01/ex00/main.cpp b/cpp01/ex00/main.cpp index c8aa0b8..689f7f1 100644 --- a/cpp01/ex00/main.cpp +++ b/cpp01/ex00/main.cpp @@ -1,10 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/13 09:26:11 by charles #+# #+# */ +/* Updated: 2020/04/13 09:29:58 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include <iostream> #include "Pony.hpp" void ponyOnTheHeap() { Pony *p = new Pony(200, 100); - p->say_hello(); + p->sayHello(); p->run(); delete p; } @@ -12,7 +24,7 @@ void ponyOnTheHeap() void ponyOnTheStack() { Pony p(200, 100); - p.say_hello(); + p.sayHello(); p.run(); } |
