-
Notifications
You must be signed in to change notification settings - Fork 84
/
Demo.cpp
52 lines (38 loc) · 1.22 KB
/
Demo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Demo file for the exercise on binary tree
*
* @author Evgeny Hershkovitch Neiterman
* @since 2023-03
*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdexcept>
#include <cassert>
using namespace std;
#include "sources/Team.hpp" //no need for other includes
using namespace ariel;
int main() {
Point a(32.3,44),b(1.3,3.5);
assert(a.distance(b) == b.distance(a));
Cowboy *tom = new Cowboy("Tom", a);
OldNinja *sushi = new OldNinja("sushi", b);
tom->shoot(sushi);
cout << tom->print() <<endl;
sushi->move(tom);
sushi->slash(tom);
Team team_A(tom);
team_A.add(new YoungNinja("Yogi", Point(64,57)));
// Team b(tom); should throw tom is already in team a
Team team_B(sushi);
team_B.add(new TrainedNinja("Hikari", Point(12,81)));
while(team_A.stillAlive() > 0 && team_B.stillAlive() > 0){
team_A.attack(&team_B);
team_B.attack(&team_A);
team_A.print();
team_B.print();
}
if (team_A.stillAlive() > 0) cout << "winner is team_A" << endl;
else cout << "winner is team_B" << endl;
return 0; // no memory issues. Team should free the memory of its members. both a and b teams are on the stack.
}