summaryrefslogtreecommitdiff
path: root/graphs/cpp/war/soldier.cc
blob: 01dc57c15191a39b5f2138752b8193f4d609e3ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "soldier.hh"

#include <iostream>

Soldier::Soldier(int hp, int dmg, std::string scream)
    : health_points_{ hp }
    , damage_{ dmg }
    , scream_{ scream }
{}

void Soldier::print_state() const
{
    std::cout << "I have " << health_points_ << " health points.\n";
}

void Soldier::scream() const
{
    std::cout << scream_ << "\n";
}

void Soldier::attack(Soldier& s)
{
    s.health_points_ -= this->damage_;
}