32 lines
523 B
C++
32 lines
523 B
C++
|
/*
|
|||
|
* 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;
|
|||
|
}
|