Sponsored Links


Results 1 to 1 of 1

Thread: Object Oriented Programming (CS304) Assignment No.4 solution 12/01/2011

  1. #1
    Administrator Xpert's Avatar
    Join Date
    May 2010
    Location
    Jhelum
    Posts
    6,239

    Object Oriented Programming (CS304) Assignment No.4 solution 12/01/2011

    Sponsored Links1


    Assignment

    Introduction:

    In Assignment No.1 you developed Object Oriented Model for Library Management System and in Assignment #2 you developed its practical prototype in c++ that you didn’t give actual implementation in c++ but simple stereotype (sketch) in the form of c++ code mentioning class names their parameters and functions with access specifiers you also showed the relationship between classes in the form of inheritance mentioning the name of class/classes from which they have been derived in proper c++ syntax.

    Sponsored Links


    Description:

    As you know in a header file (.h) for a class we include its declaration while in implementation file (.cpp) part we add implementation of all methods of that class. In this assignment you have to do exactly the same for only one class in your Dev c++ project you already had created in Assignment No.2 (Library Management System), you have to add the following for each class,

    1. Necessary attributes with suitable data types in its header file (Data Members)
    2. Constructor and Destructor of that class
    3. Getters and Setters for all its Data Members (also make them const where required)
    Important Note:

    • In this assignment code given for any class (Library, student, administrator etc) should be correct however you are NOT required to create this class’s objects and call their methods in main these things might be required in next assignment.
    • Although it is not requirement you can start from code generated using argoUML for each class.


    Uploading Instructions:

    You have to upload your single zipped dev c++ project as you did in Assignment No. 2 and 3
    Appendix:

    Example code for a Course class to store any course attributes is given below similarly you have to add code for all your classes in your Dev c++ project,


    Course.h
    Code:
    #include <iostream>
    using namespace std;
    
    
    class Course {
    
     public:
       
        Course(char * , char * , int ); 
        void setName(char *);
        char *getName() const ;
        void setCode(char *);
        char *getCode() const ;
        int gerCreditHours();
        void setCreditHours(int);
        int getCreditHours()const ;
        ~Course(); 
    
     private:
         
        char *name;
        char *code;
        int credithours;
      
    };
    Course.cpp
    Code:
    Course::Course(char * _name, char * _code, int _credithours)
    
    {
          name = new char[strlen(_name)];
          strcpy(name,_name);
          code  = new char[strlen(_code)];
          strcpy(code,_code);
          credithours = _credithours;
    
     }
    
    void Course::setName(char * _name)
    
    {
         if ( name !=NULL ) delete []name;
          name = new char[strlen(_name)];
          strcpy(name,_name);
        
    }
    
    char * Course::getName() const 
    
    {
      return name;
        
    }
    
    void Course::setCode(char * _code) 
    
    {
          if (code != NULL) delete []code;
          code  = new char[strlen(_code)];
          strcpy(code,_code);
    
        
    }
    
     char * Course::getCode() const 
    
    {
      return code;
        
    }
    
    void Course::setCreditHours(int _credithours )
    
    {
       credithours = _credithours;
        
    }
    
    int Course::getCreditHours() const 
    
    {
      return credithours;
        
    }
    
    Course::~Course()
    {
      if(name != NULL) delete []name;
      if (code != NULL) delete []code;
    }
    Solution can be found in the attachment
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. CS304- Object Oriented Programming Solution of Assignment No. 02 (Graded) 2013
    By vuassignments in forum Assignments & Solutions
    Replies: 1
    Last Post: 11-29-2013, 10:24 PM
  2. Replies: 33
    Last Post: 12-30-2011, 03:39 PM
  3. Replies: 17
    Last Post: 07-01-2011, 03:09 AM
  4. Replies: 23
    Last Post: 06-12-2011, 06:20 PM
  5. Replies: 0
    Last Post: 05-07-2010, 01:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft