Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
stdin-employee-factory.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the gobelijn software.
3  * Gobelijn is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the
5  * Free Software Foundation, either version 3 of the License, or any later
6  * version. Gobelijn is distributed in the hope that it will be useful, but
7  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8  * or FITNESS FOR A PARTICULAR PURPOSE.
9  * See the GNU General Public License for details. You should have received
10  * a copy of the GNU General Public License along with the software. If not,
11  * see <http://www.gnu.org/licenses/>.
12  *
13  * Copyright 2016, Jan Broeckhove.
14  */
20 #include "stdin-employee-factory.h"
21 
22 #include <iostream>
23 
24 namespace AbstractFactory {
29 {
30  // Use standard input to create the Employee instance.
31  // Print some values to stdout to make sure the user knows what is expected of them.
32  Employee result;
33  std::cout << "Hi, there. What's your name?" << std::endl;
34  std::getline(std::cin, result.Name);
35  std::cout << "Great! And what's your department?" << std::endl;
36  std::getline(std::cin, result.DepartmentName);
37  std::cout << "All right. One final question: what's your salary?" << std::endl;
38  std::cin >> result.Salary;
39  return result;
40 }
41 } // namespace AbstractFactory
double Salary
Stores the employee's monthly wage.
Definition: employee.h:34
Employee Create() final
Instructs this factory to create a value.
std::string DepartmentName
Stores the name of the employee's department.
Definition: employee.h:33
std::string Name
Stores the person's name.
Definition: employee.h:32
A data structure that represents an employee's data.
Definition: employee.h:28
Concrete stdin input based factory.