Friday , 22 November 2024

CS304 Assignments # 2 Solution Spring 2012

Class Diagram for Assignment No. 2

 

Figure 1: Object Model of Song Library System

 Also note that you don’t have to 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 have to show the relationship (inheritance, association, aggregation, composition) between classes in proper c++ syntax with comments.

Note: Every student will follow the above mentioned Object Model in order to develop solution of assignment No.2.

Example Object Model and its Prototype

#include<iostream.h>

#include<conio.h>

 

class Lesson{ // Lesson class

// Lesson class attributes

// Access specifier is by default private

int ID;

topic * title;//aggregation relationship b/w lessons and topic

int NoOfLessons;

public:// public access specifier

 

// Lesson class functions/ operations

void add();

void remove();

bool select();


void search();

void View();

void print();

void download();

};// end of Lesson class

// ************************************************************

// ************************************************************

// ************************************************************

class course{ //course class

//Attributes of course class

char * code;

topic  title;    //composition relationship b/w Course and topic

char * courseName;

int duration;

Lesson NoOfLessons;//composition relationship b/w Course and Lesson

 

public:// public access specifier

 

//course class functions/operations

void add();

bool select();

void View();

void read();

};// end of course class

// ************************************************************

// ************************************************************

// ************************************************************

 

class StudyProgram{ // StudyProgram class

//Attributes of StudyProgram

// Access specifier is by default private

char * Code;

char * title;

char * ProgramName;

course duration; //composition relationship b/w StudyProgram and course

public:// public access specifier

bool select();

char * ViewCourseList;

};// end of StudyProgram class

 

// ************************************************************

// ************************************************************

// ************************************************************

 

class topic{ // topic class

//topic class attributes

// Access specifier is by default private

int ID;

char * title;

 

public: // public access specifier

 

// topic class functions/ operations

void add();

void remove();

bool select();

void search();

void View();

void print();

void download();

};// end of topic class

// ************************************************************

// ************************************************************

// ***********************************************************

 

/****************** Assignment No. 2 : Solution **********************\

#include <iostream.h>
#include <string.h>
#include <stdlib.h>

using namespace std;
class User;
class Band;
class Track;
class Album;
class Artist;
class Listener;
class POP_Music;
class Film_Music;
class Folk_Music;
class Classic_Music;
class MusicItems;
class MusicCategory;
class Administrator;
class SongLibrarySystem;

 
class User //User class prototype
{
private:

int ID;
string Name;

public:
void playTrack();
void getName();
void getID();

};

class Listener:User //Listener class prototype and its relation with base class User, here Listener is child class
{
public:
void playTrack();

};

class Administrator:User //Administrator class prototype and its relation with base class User, here Listener is child class
{
private:
string Password;

public:
void getPassword();
bool addTrack();
bool deleteTrack();
bool updateTrack();
bool addArtist();
bool deleteArtist();
bool updateArtist();
bool addAlbum();
bool deleteAlbum();
bool updateAlbum();
bool addMusicCategory();
bool deleteMusicCategory();
bool updateMusicCategory();

};
class SongLibrarySystem //SongLibrarySystem class prototype which have aggregation relationship with User and Music Items
{
private:
User *user;
MusicItems *musicitem;

public:
void getUser();
void getMusicItem();
};

class MusicCategory //MusicCategory class prototype which have composition relationship with Music Items Also have four child classes as well along with aggregation relation with Band and Artist
{
private:
Artist *artist;
Band *band;


public:
void getAlbum();
void getTrack();
void getArtist();

};

class MusicItems //MusicItems class prototype which have aggregation relationship with Song Library System
{
private:
MusicCategory musiccategory;

public:
void getMusicCategory();
void getAlbum();
void getArtist();
void getTrack();
void getBand();

};

class Folk_Music:MusicCategory // Folk_Music class prototype which is inherited from MusicCategory
{

public:
void getBand();
void getArtist();

};

class Film_Music: MusicCategory //Film_Music class prototype which is inherited from MusicCategory
{
public:
void getBand();
void getArtist();

};
class POP_Music: MusicCategory //POP_Music class prototype which is inherited from MusicCategory
{

public:
void getBand();
void getArtist();

};

class Classic_Music: MusicCategory //Classic_Music class prototype which is inherited from MusicCategory
{
public:
void getBand();
void getArtist();

};

class Track //Track class prototype which have composition relation with Artist and Album
{
private:
string TrackName;
int TrackId;
string Lyrics;

public:
void playTrack();
void stopTrack();
void pauseTrack();
void downloadTrack();
void getTrackName();
void getTrackID();
void getLyrics();

};

class Album //Album class prototype which have composition relation with Artist
{
private:
int AlnumID;
string AlbumTitle;
int TrackNumber;
int Year;
Track track;

public:
void getTrack();
void vewTrack();
void vewTracknumber();
void viewYear();
void getAlbumID();
void getTitle();

};

class Artist //Artist class prototype which have aggregation relation with Music Category

{
private:
string ArtistName;
Album Albums;
Track Tracks;

public:
void getTrack();
void getAlbum();
void getArtistName();
void getMusicCategory();

};

class Band //Band class prototype which have aggregation relation with Music Category and composition relationship with Artist

{
private:
Artist art;
string BandName;
string BandDetails;

public:
void getArtist();
void getBandDetails();
void getBandName();
};
main ()
{
cout<<“This is just a prototype of all classes”;
cout<<endl;
system(“PAUSE”);

}

 /****************** Download Solution from Here **********************\

 

Spring 2012_CS304_2_SOL

Check Also

CS304 Unsolved Final Term Paper Spring 2010

Question No: 1    ( Marks: 1 )    – Please choose one  Classes like TwoDimensionalShape and …

Leave a Reply

Your email address will not be published. Required fields are marked *

*