Design Pattern Examples
Overview of object-oriented design patterns
Strategy_EntryInformation.h
Go to the documentation of this file.
1
5
6#pragma once
7#ifndef __STRATEGY_ENTRYINFORMATION_H__
8#define __STRATEGY_ENTRYINFORMATION_H__
9
10#include <memory>
11#include <string>
12
13#include "helpers/formatstring.h"
14
16{
17
22 {
26 using shared_ptr_t = std::shared_ptr<EntryInformation>;
27
31 std::string Name;
32
36 int Age;
37
41 int Height;
42
49 EntryInformation(std::string name, int age, int height)
50 : Name(name)
51 , Age(age)
52 , Height(height)
53 {
54 }
55
56
62 std::string ToString()
63 {
64 return Helpers::formatstring("%6s %3d %3d\"", Name.c_str(), Age, Height);
65 }
66 };
67
68} // end namespace
69
70#endif // __STRATEGY_ENTRYINFORMATION_H__
71
The namespace containing all Design Pattern Examples implemented in C++.
std::string formatstring(const char *fmt,...)
Use the given string and arguments to return a buffer containing the formatted string....
Represents an individual with a Name, Age, and Height.
EntryInformation(std::string name, int age, int height)
Constructor.
int Age
Age of this individual, in years.
std::string ToString()
Convert the entry into a string. In this case, a formatted string where name, age,...
std::shared_ptr< EntryInformation > shared_ptr_t
Alias to make it easier to work with a shared pointer.
int Height
Height of this individual, in inches.
std::string Name
Name of this individual.