This repository has been archived on 2022-11-09. You can view files and clone it, but cannot push or open issues or pull requests.
patterns-old/lesson_6/OpenCommand.cpp

32 lines
523 B
C++
Raw Normal View History

2021-11-04 19:47:40 +00:00
/*
* OpenCommand.cpp
*
* Created on: 4 нояб. 2021 г.
* Author: alexander
*/
#include "OpenCommand.hpp"
#include "Document.hpp"
OpenCommand::OpenCommand(Application *a) : _application(a)
{
}
void OpenCommand::Execute()
{
std::string name = AskUser();
if (!name.empty())
{
Document *document = new Document(name);
_application->Add(document);
document->Open();
}
}
std::string OpenCommand::AskUser()
{
std::string name;
std::cin >> name;
return name;
}