aboutsummaryrefslogtreecommitdiff
path: root/cpp04/ex02/main.cpp
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-11-13 14:43:17 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-11-13 14:43:17 +0100
commit4c30e98f4a4018a25d3a9f3ee790d589be803cb0 (patch)
tree655a4bd52a7a6633a32782eab935fb01a47040e9 /cpp04/ex02/main.cpp
parentb8e39b947890e74d82530e25ad9d02668aae1f0c (diff)
downloadpiscine_cpp-4c30e98f4a4018a25d3a9f3ee790d589be803cb0.tar.gz
piscine_cpp-4c30e98f4a4018a25d3a9f3ee790d589be803cb0.tar.bz2
piscine_cpp-4c30e98f4a4018a25d3a9f3ee790d589be803cb0.zip
Added main for cpp04/ex01 and cpp04/ex02, Fixed cpp04/03 MateriaSource
Diffstat (limited to 'cpp04/ex02/main.cpp')
-rw-r--r--cpp04/ex02/main.cpp116
1 files changed, 104 insertions, 12 deletions
diff --git a/cpp04/ex02/main.cpp b/cpp04/ex02/main.cpp
index 137ce46..c53dadb 100644
--- a/cpp04/ex02/main.cpp
+++ b/cpp04/ex02/main.cpp
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/14 15:50:35 by charles #+# #+# */
-/* Updated: 2020/04/14 15:53:35 by charles ### ########.fr */
+/* Updated: 2020/11/13 12:36:22 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,20 +18,112 @@
int main()
{
- ISpaceMarine* bob = new TacticalMarine;
- ISpaceMarine* jim = new AssaultTerminator;
+ {
+ std::cout << "================ SUBJECT MAIN =====================" << std::endl;
+ ISpaceMarine* bob = new TacticalMarine;
+ ISpaceMarine* jim = new AssaultTerminator;
+
+ ISquad* vlc = new Squad;
+ vlc->push(bob);
+ vlc->push(jim);
+ for (int i = 0; i < vlc->getCount(); ++i)
+ {
+ ISpaceMarine* cur = vlc->getUnit(i);
+ cur->battleCry();
+ cur->rangedAttack();
+ cur->meleeAttack();
+ }
+ delete vlc;
+ }
+
+ std::cout << std::endl;
+
+ {
+ std::cout << "================ TACTICAL MARINE =====================" << std::endl;
+ TacticalMarine t;
+ t.battleCry();
+ t.rangedAttack();
+ t.meleeAttack();
+ TacticalMarine t2(t);
+ TacticalMarine t3;
+ t3 = t;
+ std::cout << "################ INTERFACE" << std::endl;
+ ISpaceMarine *sm = new TacticalMarine();
+ sm->battleCry();
+ sm->rangedAttack();
+ sm->meleeAttack();
+ delete sm;
+ }
+
+ std::cout << std::endl;
- ISquad* vlc = new Squad;
- vlc->push(bob);
- vlc->push(jim);
- for (int i = 0; i < vlc->getCount(); ++i)
{
- ISpaceMarine* cur = vlc->getUnit(i);
- cur->battleCry();
- cur->rangedAttack();
- cur->meleeAttack();
+ std::cout << "================ ASSAULT TERMINATOR =====================" << std::endl;
+ AssaultTerminator a;
+ a.battleCry();
+ a.rangedAttack();
+ a.meleeAttack();
+ AssaultTerminator a2(a);
+ AssaultTerminator a3;
+ a3 = a;
+ std::cout << "################ INTERFACE" << std::endl;
+ ISpaceMarine *sm = new AssaultTerminator();
+ sm->battleCry();
+ sm->rangedAttack();
+ sm->meleeAttack();
+ delete sm;
+ }
+
+ std::cout << std::endl;
+
+ {
+ std::cout << "================ SQUAD =====================" << std::endl;
+ Squad s;
+ std::cout << "Count: " << s.getCount() << std::endl;
+ s.push(new TacticalMarine());
+ std::cout << "Count: " << s.getCount() << std::endl;
+ s.push(new TacticalMarine());
+ s.push(new AssaultTerminator());
+ s.push(new AssaultTerminator());
+ std::cout << "Count: " << s.getCount() << std::endl;
+ s.getUnit(0)->battleCry();
+ s.getUnit(1)->battleCry();
+ s.getUnit(2)->battleCry();
+ s.getUnit(3)->battleCry();
+ s.getUnit(3)->rangedAttack();
+ s.getUnit(3)->meleeAttack();
+ s.getUnit(0)->rangedAttack();
+ s.getUnit(0)->meleeAttack();
+ std::cout << s.getUnit(4) << std::endl;
+ std::cout << s.getUnit(-1) << std::endl;
+
+ std::cout << "################ COPY" << std::endl;
+ Squad s2(s);
+ std::cout << "Copy Count: " << s2.getCount() << std::endl;
+ s2.push(new TacticalMarine());
+ std::cout << "Copy Count: " << s2.getCount() << std::endl;
+ std::cout << "Origin Count: " << s.getCount() << std::endl;
+
+ std::cout << "################ ASSIGN" << std::endl;
+ Squad s3;
+ s3 = s;
+ std::cout << "Copy Count: " << s3.getCount() << std::endl;
+ s3.push(new TacticalMarine());
+ std::cout << "Copy Count: " << s3.getCount() << std::endl;
+ std::cout << "Origin Count: " << s.getCount() << std::endl;
+
+ std::cout << "################ INTERFACE" << std::endl;
+ ISquad *si = new Squad();
+ si->push(new TacticalMarine());
+ std::cout << si->getCount() << std::endl;
+ si->getUnit(0)->battleCry();
+ si->push(new AssaultTerminator());
+ std::cout << si->getCount() << std::endl;
+ si->getUnit(1)->battleCry();
+ delete si;
+
+ std::cout << "################ DESTROY" << std::endl;
}
- delete vlc;
return 0;
}