vendredi 11 juin 2021

Can anyone help me with the implementation of program that use stl list in c++

I’m trying to learn c++ and now i have to face the implementation of a program which ask me to create a list of geeks and a list of projects to work on. For each geek I have to store his id number and his salary, and for each project I have to store the name of it and his Id number. Then it asks me to associate a specific geek to a specific project.

So my ideas is create a geek.h with information of geek class and the set/get function , than create a project.h with information of project class and set/get function ,and than i would like to implement a addinformation function into a main.cpp and another function to link a specific geek to a project . now i'm struggling a lot here is my partial code

#include<iostream>
#include<vector>
#include<list>
#include<string>
//geek.h
using std::cout;
using std::cin;
using std::vector;
using std::list;
using std::string;
class geek
{
  friend class project;
  private:
  int id_geek;
  double hour_salary;
  public:
      geek(int i,double  h) : id_geek{i},hour_salary{h} {}
      void setid(int id)
  {
      id_geek=id;
  }
  void seths(double hs)
  {
      hour_salary=hs;
  }
  int getid()
  {
      return id_geek;
  }
  double geths()
  {
     return hour_salary;
  }
};

#include<iostream>
#include<vector>
#include<list>
#include<string>
#include<iterator>
#include"geek.h"
//project.h
using std::iterator;
using std::vector;
using std::list;
using std::string;

class project: public geek
{
    friend class geek;
    private:
    int id_project;
    string project_name;
    double total_amount;
    double delivery_date;
    list<project> projectlist;
    public:
    project(int id,string pn,double ta,double dd,int idg,double hr) :id_project{id},project_name{pn},total_amount{ta},delivery_date{dd},geek(idg,hr) {}
    void setid(int id)
    {
        id_project=id;
    }
    void setpn(string pn)
    {
       project_name=pn;
    }
    void setta(double ta)
    {
        total_amount=ta;
    }
    void setdd(double dd)
    {
        delivery_date=dd;
    }
    int getid()
    {
        return id_project;
    }
    string getpn()
    {
        return project_name;
    }
    double getta()
    {
        return total_amount;
    }
    double getdd()
    {
        return delivery_date;
    }
};


#include<iostream>
#include<vector>
#include<list>
#include<string>
#include"project.h"
#include"geek.h"
//fantaware.cpp
using std::vector;
using std::list;
using std::string;

int main()
{
list<geek> geeklist;
list<project> projectlist;
int id ;
double salary;
  void Addgeekinfo(geek g)  
  {
     cout <<"insert geek id:";
     cin >> id;
     cout<<"insert geek salary;";
     cin>>salary;

     (now how do i use geeklist.push-front(?) in order to put elements into the list??)
     (ll have the same prob with aggproject info that's why i did nit read it yet)

     (how can i create a function to link a geek to a project) 
  }
}

`

`

Aucun commentaire:

Enregistrer un commentaire