write a class called Book to store the attributes of a book and do the required operations on it.In particular , it should have the following protected data members
title-string ,author -array of string ,size=4,ISBN-string,publisher-string,year of publiication-int.Note that ISBN is a 13 digit integer number and it is unique for every book.You can use a string for it
it should have a constructor function with default parameters ,set,and get function for each of the data members and a print function to print all the attributes of the book
B.Write a class called LibraryBook,which inherites the properties of the class Book with inheritance type as public . This class has the following additional data members
accession number(integer between 1 and 1000),rack number(integer between 1 and 100).Note that the rack number gives the rack on which the book is placed in the library
Include a constructor function with parameters , set and get functions for assession number and rack number and a print function to print all the attributes of a library book(including that of Book),!!!
c.write main function to test all functionalities of your classs
This is my trying
can u help me
plzzzzzzzz
#include<iostream>
#include<string>
using namespace std;
class Book
{
protected:
string title;
string author[4];
string ISBN;
string publisher;
int year,numofauthor;
public:
Book(string t=" ",string auth[]={" "},string i=" " , string p,int y=2000);
void setTittle(string);
void setAuthor[](string);
void setisbn(string);
void setPublisher(string);
void setYear(int);
string getTittle(string&);
string getAuthor[](string&);
string getisbn(string&);
string getpublisher(string&);
int getYear(int&);
void print();
};
Book::Book(string t=" ",string auth[]={" "},string i=" " , string p,
int y=2000)
{
title=t;
for(int x=0; x<numauthor;x++)
author[x]=a[x];
ISBN=i;
publisher=p;
year=y;
}
void Book::setTittle(string t)
{
tittle=t;
}
void Book::setAuthor[](string auth[])
{
if(size>4)
size=4;
numauthor=size;
for (int i=0; i<size; i++)
author[i]=a[i];
}
void Book::setisbn(string i)
{
ISBN=i;
}
void Book::publisher(string p)
{
publisher=p;
}
void Book::setYear(int y)
{
year=y;
}
string Book::getTitle()
{
return title;
}
string Book::getAuthor[]()
{
return author[];
}
string Book::getisbn()
{
return ISBN;
}
string Book::getPublisher()
{
return publisher;
}
string Book::getYear()
{
return year;
}
string Book::print()
{
cout<<" Tittle :" << tittle <<endl;
cout<<" Author :" ;
for(int i=0;i<numofauthor;i++)
{
cout<<author[i]<<" "<<endl;
}
cout<<" ISBN :"<<ISBN<<endl;
cout<<" publisher "<< publisher<<endl;
cout<<" YEAR :"<<endl;
}
class LibarayBook: public Book
{
protected:
int acc_num[1000];
int rac_num[100];
public:
LibarayBook( int acc[]=0,int rac[]=0);
void setAcc_num[](int);
void setRac_num[](int);
int getAcc_num[]();
int getRac_num[]();
void print();
};
LibarayBook::LibarayBook(int acc[], int rac[],string t=,string auth[],
string i= , string p,int y):Book(t,auth[],i,p,y)
{
acc_num=acc[];
rac_num=rac[];
}
void LibarayBook::setAcc_num[](int acc[])
{
acc_num[]=acc[];
}
void LibarayBook::setRac_num[](int rac[])
{
rac_num[]=rac[];
}
int LibarayBook::getAcc_num[]()
{
return acc_num[];
}
int LibarayBook::getAcc_num[]()
{
return rac_num[];
}
void LibarayBook::print()
{
cout<<"Book":<<endl;
Book::print();
cout<<endl;
cout<<"accession number:"<<endl;
for(int i=0;i<1000;i++)
cout<<acc_num[i]<<endl;
cout<<" rack number :"<<endl;
for(int i=0;i<100;i++)
cout<<rac_num[i]<<endl;
}
int main()
{
LibarayBook L;
L.setYear(2010);
L.print();
return 0;
}
Edited by WingedPanther, 17 July 2010 - 12:12 PM.


Sign In
Create Account

Back to top









