publicclass Organization
{
// instance variables
ArrayList<Employee> list = new ArrayList<Employee>();
private String Google , Mircrosoft;
/*
* Default constructor
*/
public Organization()
{
}
/*
* Add employee then check if has same employee , same organization
*/
publicvoid addEmployee(Employee e)
{
for (Employee elist : list )
{if (elist.getEmployeeName().equals( e.getEmployeeName())&&(elist.getEmployeeSex().equals( e.getEmployeeSex()))&&
(elist.getEmployeeBD().equals( e.getEmployeeBD()))&&(elist.getEmployeeOr().equals(e.getEmployeeOr())))
System.out.println("Same person found");
if ( elist.getEmployeeOr().equals( e.getEmployeeOr()))
System.out.println("Same Organization found");
}
list.add(e);
}
/*
* Return entire list of employees
*/
public ArrayList <Employee> getEmployees()
{
return list;
}
/*list all employees to console
*
*/
publicvoid showEmployees()
{
for ( Employee em : list)
{
System.out.println(em.toString());
}
}
/*list all programmers including their language to console – use instanceOf
*/
publicvoid showProgrammers()
{//cast
for(int i = 0; i > list.size(); i++)
{
if(list.get(i) instanceof Programmer)
{
Programmer pr = (Programmer)list.get(i);
System.out.println(pr.toString());
}
}
}
/*
* list all testers including their programmers name and their
* language to console – use instanceOf
*/
publicvoid showTesters()
{
for(int i = 0; i > list.size(); i++)
{
if(list.get(i) instanceof Tester)
{
Tester t = (Tester)list.get(i);
System.out.println(t.toString());
}
}
#include <string>
class Organization
{
// instance variables
public:
typedef std::vector<Employee*> EmployeeList;
EmployeeList list;
private:
std::string Google, Mircrosoft;
public:
/*
* Default constructor
*/
Organization()
{
}
/*
* Add employee then check if has same employee , same organization
*/
void addEmployee(const Employee* e)
{
for (const Employee* elist : list)
{
if (elist->getEmployeeName() == e->getEmployeeName() &&
elist->getEmployeeSex() == e->getEmployeeSex() &&
elist->getEmployeeBD() == e->getEmployeeBD() &&
elist->getEmployeeOr() == e->getEmployeeOr())
std::cout << "Same person found" << std::endl;
if (elist->getEmployeeOr() == e->getEmployeeOr())
std::cout << "Same Organization found" << std::endl;
}
list.push_back(e);
}
/*
* Return entire list of employees
*/
const EmployeeList& getEmployees() const
{
return list;
}
/*list all employees to console
*
*/
void showEmployees() const
{
for (const Employee* e : list)
{
std::cout << *em << std::endl;
}
}
/*list all programmers including their language to console – use instanceOf
*/
void showProgrammers() const
{//cast
for (int i = 0; i > list.size(); i++) // you realise that this loop is incorrect, right?
{
if (const Programmer* pr = dynamic_cast<const Programmer*>(list[i]))
{
std::cout << *pr << std::endl;
}
}
}
/*
* list all testers including their programmers name and their
* language to console – use instanceOf
*/
void showTesters() const
{
for (int i = 0; i > list.size(); i++) // you realise that this loop is incorrect, right?
{
if (const Tester* t = dynamic_cast<const Tester*>(list[i]))
{
std::cout << *t << std::endl;
}
}
// WHERE's THE REST OF IT?