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 layout

class layout

Scheduled Pinned Locked Moved C#
databasequestionannouncement
2 Posts 2 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.
  • M Offline
    M Offline
    Mike Bentzen
    wrote on last edited by
    #1

    Hello, I am trying to write an application that will be able to manage an attendance list. It will talk back to a database and any updates made to the attendance list, will update the database. So basically, there are students and classes. each class has students. I want to be able to maintain a list of students and a list of classes. How should I go about doing this? I am thinking of having the classes: student - defines a student object class - defines a class object - list studentList - contains a list of ALL students - list classList - contains a list of ALL classes - list I would like to retrieve the student list of a particular class where should the method for this go? Should it go in classList? maybe getStudents(int classID) or class? just getstudents()? i want to also be able to add students to a particular class from studentList. where should the addStudentToClass method go? in the class or in the classList? If it belongs in class, how do you get access to the studentList? do I have to pass the studentList as a variable through the constructor when i create the class? I know I can do it by making the studentList a static class then i can access the method by students.Add(studentList.GetStudentByID(int studentID))? I would appreciate it greatly if someone could explain the levels of access and what classes should be able to access what by using the scenario above. Thank you, Kind Regards, Mike

    C 1 Reply Last reply
    0
    • M Mike Bentzen

      Hello, I am trying to write an application that will be able to manage an attendance list. It will talk back to a database and any updates made to the attendance list, will update the database. So basically, there are students and classes. each class has students. I want to be able to maintain a list of students and a list of classes. How should I go about doing this? I am thinking of having the classes: student - defines a student object class - defines a class object - list studentList - contains a list of ALL students - list classList - contains a list of ALL classes - list I would like to retrieve the student list of a particular class where should the method for this go? Should it go in classList? maybe getStudents(int classID) or class? just getstudents()? i want to also be able to add students to a particular class from studentList. where should the addStudentToClass method go? in the class or in the classList? If it belongs in class, how do you get access to the studentList? do I have to pass the studentList as a variable through the constructor when i create the class? I know I can do it by making the studentList a static class then i can access the method by students.Add(studentList.GetStudentByID(int studentID))? I would appreciate it greatly if someone could explain the levels of access and what classes should be able to access what by using the scenario above. Thank you, Kind Regards, Mike

      C Offline
      C Offline
      carbon_golem
      wrote on last edited by
      #2

      Recommendations: 1) Don't use "class" for a class name... really don't. use "Course" or something appropriate. Never use keywords as class names or in parts of class names. 2) If it has to do with the class directly, then put it into that class. i.e. I'd put public static GetStudent() into the Student class. 3) Remember the "has-a" and "is-a" relationship. Curriculum has Courses. Courses have Students. I don't think you have a problem that requires inheritance here, so don't worry about the "is-a" relationship. 4) When you have problems getting started, it helps greatly to do the UML, even if it's sloppy who cares as long as you get a better understanding of the problem. Use a pencil and paper, don't worry about visio or other fancy tools. Pencils are twice as fast as visio - easy. 5) I presume that this is a student assignment? I'll give you a hint here, what you have is a nested problem, if you solve the Course/Students relationship, then you solved the Curriculum/Courses relationship. Curriculum -Courses +Add(Course) +Remove(Course) +this[index] Course -Students +Add(Student) +Remove(Student) +this[index] +GetCourse(fromDB) Student -StudentInfo() //Info that I'm not going to go through. +GetStudent(fromDB) Scott P

      “It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.” -Edsger Dijkstra

      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