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
- Listener
- Administrator
Now for implementing these three classes practically in c++ you have to define classes according to the requirements given below:
- Implement data members and member functions for each class
- Implement constructor and destructor for each class
- Implement setters and getters functions for each class
- Implement different type of relations between these classes
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<<endl<<“\nEnter Title: “;
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”<<endl;
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:”<<endl;
int select;
if (select==1)
cout<<“\nTopic is selected”<<endl;
else
cout<<“\nTopic is not selected”<<endl;
}
int search(){
cout<<“In Search Mehtod:”<<endl;
int found=0;
if (found)
return 1;
else
return 0;
}
void View() {
cout<<“Viewing the Information”;
cout<<“\n*****************************************\n”;
cout<<“\nTitle is:”<< Title ;
cout<<endl<<“\nDescription is:”<<discription[100];
cout<<“\n*****************************************\n”;
}
void print(){
cout<<“\n*****************************************\n”;
cout<<endl<<“\nPrinting the Information:”<<endl;
cout<<“Title:”<<Title<<endl<<“Discription:”<<discription;
cout<<“\n*****************************************\n”;
}
void download(){
cout<<“\n*****************************************\n”;
cout<<“\nDownloading the information:”<<endl;
cout<<“Downloading under processing, Please wait:”<<endl;
cout<<“You are downloding the following:”<<endl<<Title<<“file”;
cout<<” and the following discription”<<endl<<discription<<“File”;
cout<<“\n*****************************************\n”;
}
void remove(){
cout<<“\n*****************************************\n”;
cout<<“\nDeleting the information”<<endl;
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:”<<endl;
cin.getline(dChar,200,’\n’);
}
int getSubID(){
return SubID;
}
void setTitle(){
char pChar[50];
char dChar[200];
cout<<endl<<“Enter Title : “;
cin.getline(pChar,50);
cout<<endl<<“Enter Title discription:”;
cin.getline(dChar,200);
if(strlen(dChar)>=90){
cout<<“Eligible for being a topic”<<endl;
}
else
{
cout<<“Title just contains name and no description”<<endl;
}
}
~SubTopic(){
}
};
/****************** Assignment No. 3 : Solution **********************\
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
//User Class
class User{
// Data members of user class
int Id;
char * name;
//Public interface of user class
public:
//Default Constructor
User(){
Id=-1;
name=NULL;
}
//parametrized constructor
User(int id, char *name){
Id=id;
this->name=new char[strlen(name)+1];
strcpy(this->name,name);
}
//Setter and Getter functions
void setId(int id) {
Id = id;
}
int getID(){
return Id;
}
void setName(char *name) {
this->name=new char[strlen(name)+1];
strcpy(this->name,name);
}
char * getName(){
return name;
}
void playTrack()
{
cout<<” Start playing the current track”;
}
};
//Listener Class
class Listener : public User{
//Public interface of user class
public:
void playTrack()
{
cout<<” Overloaded Method…”;
cout<<” Start playing the current track”;
}
};
//Administrator Class
class Administrator : public User{
// Data members of user class
char * Password;
//Public interface of user class
public:
void getPassword(char * password)
{
cout<<” Map password in DB”;
cout<<” Allow access to the system accordingly”;
}
/* Following code requires existence of Track, Album, Artist, and MusicCategory Classes to be implemented for execution*/
/*
//Manipulating interfaces for Track
Track * addTrack(){
cout<<“\n*****************************************\n”;
cout<<“\n Adding new Track using add method”;
cout<<“\n*****************************************\n”;
Track track = new Track(“Track Title”);
return track;
}
void deleteTrack(Track * track){
cout<<“\n*****************************************\n”;
cout<<“\n Deleting the Track”<<endl;
cout<<“\n*****************************************\n”;
delete [] track;
}
Track * updateTrack(Track * track){
cout<<“\n*****************************************\n”;
cout<<“\n Updating Code comes here for the Track”<<endl;
cout<<“\n*****************************************\n”;
return track;
}
//Manipulating interfaces for Artist
Artist * addArtist(){
cout<<“\n*****************************************\n”;
cout<<“\n Adding new Artist using add method”;
cout<<“\n*****************************************\n”;
Artist artist = new Artist (“Artist Name”);
return artist;
}
void deleteArtist (Artist * artist){
cout<<“\n*****************************************\n”;
cout<<“\n Deleting the Artist”<<endl;
cout<<“\n*****************************************\n”;
delete [] artist;
}
Artist * updateArtist (Artist * artist){
cout<<“\n*****************************************\n”;
cout<<“\n Updating Code comes here for the Artist”<<endl;
cout<<“\n*****************************************\n”;
reture artist;
}
//Manipulating interfaces for Album
Track * addAlbum(){
cout<<“\n*****************************************\n”;
cout<<“\n Adding new Album using add method”;
cout<<“\n*****************************************\n”;
Album album = new Album(“Album Title”);
return album;
}
void deleteAlbum (Album * album){
cout<<“\n*****************************************\n”;
cout<<“\n Deleting the Track”<<endl;
cout<<“\n*****************************************\n”;
delete [] album;
}
Album * updateAlbum (Album * album){
cout<<“\n*****************************************\n”;
cout<<“\n Updating Code comes here for the Album”<<endl;
cout<<“\n*****************************************\n”;
reture album;
}
//Manipulating interfaces for Music Category
Track * addMusicCategory(){
cout<<“\n*****************************************\n”;
cout<<“\n Adding new Music Category using add method”;
cout<<“\n*****************************************\n”;
MusicCategory musicCategory = new MusicCategory (“Music Category”);
return musicCategory;
}
void deleteMusicCategory (MusicCategory * musicCategory){
cout<<“\n*****************************************\n”;
cout<<“\n Deleting the Music Category”<<endl;
cout<<“\n*****************************************\n”;
delete [] musicCategory;
}
MusicCategory * updateMusicCategory (MusicCategory * musicCategory){
cout<<“\n*****************************************\n”;
cout<<“\n Updating Code comes here for the Artist”<<endl;
cout<<“\n*****************************************\n”;
reture musicCategory;
}
*/
};
int main()
{
return 0;
}
/******************Download Solution File **********************\