Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. class relationships [modified]

class relationships [modified]

Scheduled Pinned Locked Moved C#
tutorial
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    netJP12L
    wrote on last edited by
    #1

    I am trying to put this into actual class and i am having difficutlties in it. I am not sure how to show relationships. I have put down some classes that it may need. Build a class called Employee reporting relationships. The class will be used as a part of some application. Its main purpose is to keep and maintain data related to the reporting relationships between employees within an organization. Employee can have zero or more managers. Manager is an employee who has one or more other employees reporting to him. Class EmployeeReportingRelationships { } Class Employee { } Class Manager:Employee { }

    modified on Wednesday, June 23, 2010 1:47 AM

    P D Y 3 Replies Last reply
    0
    • N netJP12L

      I am trying to put this into actual class and i am having difficutlties in it. I am not sure how to show relationships. I have put down some classes that it may need. Build a class called Employee reporting relationships. The class will be used as a part of some application. Its main purpose is to keep and maintain data related to the reporting relationships between employees within an organization. Employee can have zero or more managers. Manager is an employee who has one or more other employees reporting to him. Class EmployeeReportingRelationships { } Class Employee { } Class Manager:Employee { }

      modified on Wednesday, June 23, 2010 1:47 AM

      P Offline
      P Offline
      phil o
      wrote on last edited by
      #2

      I'm afraid noone will do your homework for you. Try thinking further, and come back with a more precise question.

      N 1 Reply Last reply
      0
      • P phil o

        I'm afraid noone will do your homework for you. Try thinking further, and come back with a more precise question.

        N Offline
        N Offline
        netJP12L
        wrote on last edited by
        #3

        Well, I am not asking to write exact code for me or atleast if you could engligten me with some ideas wouldn't be bad. I find hard to comphrend and put into OOP. I know how to write classes and properties but i am not so sure what to do in it.

        1 Reply Last reply
        0
        • N netJP12L

          I am trying to put this into actual class and i am having difficutlties in it. I am not sure how to show relationships. I have put down some classes that it may need. Build a class called Employee reporting relationships. The class will be used as a part of some application. Its main purpose is to keep and maintain data related to the reporting relationships between employees within an organization. Employee can have zero or more managers. Manager is an employee who has one or more other employees reporting to him. Class EmployeeReportingRelationships { } Class Employee { } Class Manager:Employee { }

          modified on Wednesday, June 23, 2010 1:47 AM

          D Offline
          D Offline
          DaveyM69
          wrote on last edited by
          #4

          So you need to break down the requirements into logical parts. Employee can have zero or more managers. So, your Employee class will need a property that has a variable size that is of type Manager. Perhaps a List<Manager> Manager is an employee... So the Manager class should derive from Employee as you have already done. ...who has one or more other employees reporting to him. So the Manager class needs an additional property that has a variable size that is of type Employee. Possibly, the extra Manager class isn't needed as checking this property is > 0 will indicate that they are manager anyway. This is what programming is all about, turning real world situations into code and in the case of OOP creating objects to represent them and adding properties to give the details/descriptions of thos objects and methods/events for the things they actually do. Not really that hard to grasp.

          Dave

          If this helped, please vote & accept answer!

          Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

          N 1 Reply Last reply
          0
          • D DaveyM69

            So you need to break down the requirements into logical parts. Employee can have zero or more managers. So, your Employee class will need a property that has a variable size that is of type Manager. Perhaps a List<Manager> Manager is an employee... So the Manager class should derive from Employee as you have already done. ...who has one or more other employees reporting to him. So the Manager class needs an additional property that has a variable size that is of type Employee. Possibly, the extra Manager class isn't needed as checking this property is > 0 will indicate that they are manager anyway. This is what programming is all about, turning real world situations into code and in the case of OOP creating objects to represent them and adding properties to give the details/descriptions of thos objects and methods/events for the things they actually do. Not really that hard to grasp.

            Dave

            If this helped, please vote & accept answer!

            Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
            BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

            N Offline
            N Offline
            netJP12L
            wrote on last edited by
            #5

            Thanks Dave, your comments were really helpful. I've given you my vote of 5. However there is still a little confusion about the relationship, how could i get a list of managers for a given employee. For example, let's say I have an employee named "Frank" and he has two managers (Sean and manager2).

            D 1 Reply Last reply
            0
            • N netJP12L

              Thanks Dave, your comments were really helpful. I've given you my vote of 5. However there is still a little confusion about the relationship, how could i get a list of managers for a given employee. For example, let's say I have an employee named "Frank" and he has two managers (Sean and manager2).

              D Offline
              D Offline
              DaveyM69
              wrote on last edited by
              #6

              You should keep a list of the managers - something like this...

              public class Employee
              {
              private string name;
              private List<Manager> managers;

              public string Name
              {
                  get { return name; }
                  set { name = value; }
              }
              
              public List<Manager> Managers
              {
                  get
                  {
                      if(managers == null)
                          return new List<Manager>();
                      return managers;
                  }
                  set { managers = value; }
              }
              

              }

              Dave

              If this helped, please vote & accept answer!

              Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
              BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

              modified on Thursday, June 24, 2010 6:04 AM

              1 Reply Last reply
              0
              • N netJP12L

                I am trying to put this into actual class and i am having difficutlties in it. I am not sure how to show relationships. I have put down some classes that it may need. Build a class called Employee reporting relationships. The class will be used as a part of some application. Its main purpose is to keep and maintain data related to the reporting relationships between employees within an organization. Employee can have zero or more managers. Manager is an employee who has one or more other employees reporting to him. Class EmployeeReportingRelationships { } Class Employee { } Class Manager:Employee { }

                modified on Wednesday, June 23, 2010 1:47 AM

                Y Offline
                Y Offline
                yu jian
                wrote on last edited by
                #7

                You should use the UML tools, visio or rational rose to draw the class diagram. The class Manager is derived from Employee, The class employee and manager is depended by clas EmployeeReportingRelationships.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups