Pages

Thursday, 22 December 2011

cs 304 Assignment no 3 Fall 2011

Assignment:

Object Model for 3rd assignment:

In this assignment you have to code/implement the below said classes in running form these classes are,

· User

· Member

· Administrator

Meaning after completion of this assignment your c++ program will be able to

1. Verify User() of the User class

2. Add member/ Delete member

3. Add admin/ Delete admin

Now for implementing these three classes practically in c++ you have to define classes according to the requirements (solution of second assignment) given below:

1. Implement data members and member functions for each class
2. Implement constructor and destructor for each class
3. Implement setters and getters functions for each class
4. Implement different type of relations between these classes

Now override the “VerifyUser()” function of the “User” class, such that:

If the “Status” is “admin”, then it displays the following message:

“The user is an administrator”

And if “Status” is “member”, then it displays the following message:

“The user is a member”

Sample Example:

//Topic class

class topic{

// Data members of Topic class

int ID;

char * Title;

char discription[200];

//Public interface of topic class

public:

//Default constructor

topic(){

ID=1;

Title=NULL;

}

//parametrized constructor

topic(int id, char *title){

ID=id;

Title=new char[strlen(title)+1];

strcpy(Title,title);

}

//setter function for ID

void setId() {

int id;

cout<<"\nEnter ID: "; cin>>id;

}

void setTitle() {

char pChar[50];

cout<<<"\nenter b=""><<"\nenter>

cin.getline(pChar,50);

Title=new char[strlen(pChar)+1];

strcpy(Title,pChar);

}

void setTitle(char * title){

Title=title;

}

void setdiscription(){

cout<<"\nplease enter discription of title"<< b=""><>

cin.getline(discription,200);

}

int getId(){

return ID;

}

char * getTitle(){

return Title;

}

void add(){

cout<<"\n*****************************************\n"; cout<<"\nAdding new information in add method"; setTitle(); setdiscription(); cout<<"\n*****************************************\n"; } bool select(){ cout<<"Topic selection Area:"<< b=""><>

int select;

if (select==1)

cout<<"\nTopic is selected"<< b=""><>

else

cout<<"\nTopic is not selected"<< b=""><>

}

int search(){

cout<<"In Search Mehtod:"<< b=""><>

int found=0;

if (found)

return 1;

else

return 0;

}

void View() {

cout<<"Viewing the Information"; cout<<"\n*****************************************\n"; cout<<"\nTitle is:"<< Title ; cout<<<"\ndescription b=""><<"\ndescription>

cout<<"\n*****************************************\n"; } void print(){ cout<<"\n*****************************************\n"; cout<<<"\nprinting the="" b=""><<"\nprinting>

cout<<"Title:"<<<<"discription:"<< b=""><<<"discription:"<<>

cout<<"\n*****************************************\n"; } void download(){ cout<<"\n*****************************************\n"; cout<<"\nDownloading the information:"<< b=""><>

cout<<"Downloading under processing, Please wait:"<< b=""><>

cout<<"You are downloding the following:"<<<<"file";< b=""><<<"file";<>

cout<<" and the following discription"<<<<"file";< b=""><<<"file";<>

cout<<"\n*****************************************\n"; } void remove(){ cout<<"\n*****************************************\n"; cout<<"\nDeleting the information"<< b=""><>

cout<<"\n*****************************************\n"; delete []Title; delete [] discription; } ~topic(){ } }; class SubTopic: public topic { int SubID; char * title; char discription[100]; public: void setSubID(){ int subid; cout<<"Enter ID of Sub topic:"; cin>>subid;

}

void setdiscription(char []){

char dChar[200];

cout<<"Enter discription of Sub topic:"<< b=""><>

cin.getline(dChar,200,'\n');

}

int getSubID(){

return SubID;

}

void setTitle(){

char pChar[50];

char dChar[200];

cout<<<"enter title="" b=""><<"enter>

cin.getline(pChar,50);

cout<<<"enter title="" b=""><<"enter>

cin.getline(dChar,200);

if(strlen(dChar)>=90){

cout<<"Eligible for being a topic"<< b=""><>

}

else

{

cout<<"Title just contains name and no description"<< b=""><>

}

}

~SubTopic(){

}

};