C++ Implementing student registration program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Warly girl
    New Member
    • Nov 2007
    • 25

    C++ Implementing student registration program

    Hi

    i have a qustion plz help me to understand and solve it
    Code:
    Phase One Problem description
    You are required to implement a student registration system. The system keeps information about the students including their id, which is an automatic number issued by the system, a name, and current number of courses. It is important to keep the count of courses a student is currently enrolled in since he is only allowed to register for 4 courses at any given point in time. The system should facilitate course registration and dropping through appropriate functions. The system should also keep record of the date in which the student enrolled.
    Information about courses is also needed. For each course, the id and number of credits is stored. The id of the course is a single string composed of two parts: a two character code specifying the major (e.g. CS for Computer Science, MA for Mathematics, EC for economics.. etc) and a serial number, which, unlike the code, is generated by the system.
    
    Task A
    Create a header file for the class student which contains the following header, then write its implementation file.				
    
    #ifndef STUDENT_H_
    #define STUDENT_H_
    
    #include <iostream>
    #include <string>
    using namespace std;
    
    class Student{
    	private:
    		static int serialId;
    		const int id;
    		string name;
    		int currentCourses;
    		bool canRegisterMore();
    		
    	public:
    		Student(string studentName);
    	
    		bool registerCourse();
    	
    		void dropCourse();
    	
    		void printDetails();
    	
    };
    #endif /*STUDENT_H_*/
    Just help me to know the meaning of each line , and what is the work of each function

    i hope to see you help in quick time
    thanks.
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Well, instead of me going through each line, why don't you post which lines you're having trouble with so we can concentrate on those?

    Comment

    • Warly girl
      New Member
      • Nov 2007
      • 25

      #3
      Thank you for your post
      but i did not undarstand the qustion above the code because iam not in good level to undrstand all english word

      i just want you to explain it , so i will no what i shall do
      sorry of my bad language
      but i just in level one and i want your help plz
      then i will try to write the code and i want you correct my mistake

      iam waiting for you

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        Part of programming is being able to look at an assignment and break it down into separate, easy to manage parts. So, what part are you working on right now, just the Task A, or the number 2?

        Comment

        • Warly girl
          New Member
          • Nov 2007
          • 25

          #5
          sorry, but i dont undarstand what do you mean
          but i can say
          iam working in task A
          but i did not undarstand this qustion
          Code:
          You are required to implement a student registration system. The system keeps information about the students including their id, which is an automatic number issued by the system, a name, and current number of courses. It is important to keep the count of courses a student is currently enrolled in since he is only allowed to register for 4 courses at any given point in time. The system should facilitate course registration and dropping through appropriate functions. The system should also keep record of the date in which the student enrolled.
          Information about courses is also needed. For each course, the id and number of credits is stored. The id of the course is a single string composed of two parts: a two character code specifying the major (e.g. CS for Computer Science, MA for Mathematics, EC for economics.. etc) and a serial number, which, unlike the code, is generated by the system.
          i want a simple explaning to it , so maybe i will know how to solve task A

          Comment

          • sicarie
            Recognized Expert Specialist
            • Nov 2006
            • 4677

            #6
            Okay, well, they way I look at this would be at least 2 classes - a student class and a course class. The student class will need the information above (as will the course class), and then you will have to create a main to allow creating and modifying students to add/drop courses (maybe creating courses as well).

            You're really going to have to come up with a more specific question than "I don't understand this" for us to help - I can read it and understand it. What part of it are you having trouble conceptualizing as code?

            Comment

            • Warly girl
              New Member
              • Nov 2007
              • 25

              #7
              thanks alot , you are patient of my qustions
              okey .. may you start with me step by step? because iam junior in C++


              Code:
              Student(string studentName);
              first, this is constructor and i know that we always use it for initializing , but here i do not no what to put in the body of it ? i do not know what the need of it

              Comment

              • sicarie
                Recognized Expert Specialist
                • Nov 2006
                • 4677

                #8
                Originally posted by Warly girl
                information about the students including their id, which is an automatic number issued by the system, a name, and current number of courses. It is important to keep the count of courses a student is currently enrolled in since he is only allowed to register for 4 courses at any given point in time. The system should facilitate course registration and dropping through appropriate functions. The system should also keep record of the date in which the student enrolled.
                So this is where you will get your data types that you need. I would recommend just sticking with the default constructor first (no string initialization yet), as it will be easier to just have get/set methods.

                Student( )

                Then what variables can you see in the above that you will need for the Student class to have?

                Comment

                • Warly girl
                  New Member
                  • Nov 2007
                  • 25

                  #9
                  okey it is easy now

                  i will initializ these data inside the constructor

                  {
                  name =0;
                  id=0;
                  currentCourses= 0;
                  }

                  is it correct ??

                  Comment

                  • sicarie
                    Recognized Expert Specialist
                    • Nov 2006
                    • 4677

                    #10
                    Originally posted by Warly girl
                    okey it is easy now

                    i will initializ these data inside the constructor

                    {
                    name =0;
                    id=0;
                    currentCourses= 0;
                    }

                    is it correct ??
                    Partially. This is why I haven't written any code yet - you identified the right variables, but the implementation is not quite correct. This is a 'constructor' so these values will be created when the object Student is created. This means your variables need types. You have the right types being assigned to two of them, but you need to tell the compiler what type everything is.

                    For example - is 0 a name? And then for id and currentCourses, you just need to prepend them with their declarations - which you have correctly identified as integers.

                    But this comes into an issue - where are you going to decide what the id is? These should be unique, so you need to make sure that there are no other existing students with this id. The easiest (not best) solution is to create an int in your main(), and use that to trigger your setID() method, just be sure to increment it every time it is used.

                    Comment

                    • Warly girl
                      New Member
                      • Nov 2007
                      • 25

                      #11
                      Partially. This is why I haven't written any code yet - you identified the right variables, but the implementation is not quite correct. This is a 'constructor' so these values will be created when the object Student is created. This means your variables need types. You have the right types being assigned to two of them, but you need to tell the compiler what type everything is.

                      For example - is 0 a name? And then for id and currentCourses, you just need to prepend them with their declarations - which you have correctly identified as integers.
                      Yes, thats right , but where i need to write the type ?
                      you mean thats why we must write the variables as parameter , like student name here :

                      Student(string studentName)
                      and then i write
                      studentName=0;
                      or what !!


                      But this comes into an issue - where are you going to decide what the id is? These should be unique, so you need to make sure that there are no other existing students with this id. The easiest (not best) solution is to create an int in your main(), and use that to trigger your setID() method, just be sure to increment it every time it is used.
                      okey , can i put function to test the id ?
                      and put inside it if statment ?

                      Comment

                      • sicarie
                        Recognized Expert Specialist
                        • Nov 2006
                        • 4677

                        #12
                        Originally posted by Warly girl
                        Yes, thats right , but where i need to write the type ?
                        you mean thats way we must write the variables as parameter , like student name here :

                        Student(string studentName)
                        and then i write
                        studentName=0;
                        or what !!
                        Well, even looking at that it's incorrect = is 0 a string like you're passing? I wouldn't pass anything to your constructor yet - you don't have to have the variables instantiate immediately upon creation (though it's a good idea to at least set them to 0 or an empty string just in case you do forget to set them later). Then after the object is created, you should have a get*() and set*() method for each so that you can manipulate them (because I'm sure you wouldn't violate good programming practice and set them as public variables). Such as getID() and setID(int i_IDNum), or getName() and setName(string s_Name).

                        The type goes directly in front of the declaration of the variable, as I said before.

                        Originally posted by Warly girl
                        okey , can i put function to test the id ?
                        and put inside it if statment ?
                        Yep. That sounds like a good idea.

                        Comment

                        • Warly girl
                          New Member
                          • Nov 2007
                          • 25

                          #13
                          Oh my God
                          i did not undarstand any thing about constructor
                          ah. it is very difucult

                          Comment

                          • sicarie
                            Recognized Expert Specialist
                            • Nov 2006
                            • 4677

                            #14
                            Here, this is a pretty good site with good code examples. I would recommend going through that to learn a bit more about OOP.

                            Comment

                            • Warly girl
                              New Member
                              • Nov 2007
                              • 25

                              #15
                              thanks alot , i will read more and more
                              but i need to solve task1 today , because it must be with me tomorow in college

                              so , pllllllllllllll llz may you help me and give me the solve of it
                              i was very tired , thats why i was absent in many lecture
                              now just help me in this task because no time
                              and i promise you ,, i will work hard and undarstand good
                              and solve the next tasks in next week
                              of course with your help

                              so , may you solve it ? for just this time ?

                              Comment

                              Working...