right basicly i need to make a class. I have a file called book.cpp which needs to be modified and i have no brain at all today.
help is so needed.
//book.cpp
#include"bookheader.hpp"
Book::Book(void)
{
title[0]='\0';
quantity = 0;
deleted = false;
}
Book::Book(string tit)
{
strcpy(title, tit.c_str());
quantity = 1;
deleted = false;
}
Book::Book(Book& b)
{
strcpy(title, b.title);
quantity = 1;
deleted = false;
}
Book::Book(const Book& b)
{
strcpy(title, b.title);
quantity = 1;
deleted = false;
}
string Book::getTitle(void)
{
return string(title);
}
void Book::increment(void)
{
quantity++;
}
void Book::mark(void)
{
deleted = true;
}
void Book::unmark(void)
{
deleted = false;
}
void Book::decrement(void)
{
quantity--;
}
int Book::getQuantity()
{
return quantity;
}
bool Book::marked(void)
{
return deleted;
}
ostream& operator<<(ostream& os, Book& b)
{
os << b.getTitle() << ":" << b.getQuantity();
if (b.marked()) os << "(deleted)";
return os;
}
bool Book::operator<(Book& b)
{
return (strcmp(title, b.title) < 0);
}
bool Book::operator==(Book& b)
{
return (strcmp(title, b.title) == 0);
}
Book& Book::operator=(Book& b)
{
if (this != &b)
{
strcpy(title, b.title);
quantity = b.quantity;
deleted = b.deleted;
}
return *this;
}
//these overloaded operators needed for STL
bool Book::operator<(const Book& b)
{
return (strcmp(title, b.title) < 0);
}
bool Book::operator==(const Book& b)
{
return (strcmp(title, b.title) == 0);
}
Book& Book::operator=(const Book& b)
{
if (this != &b)
{
strcpy(title, b.title);
quantity = b.quantity;
deleted = b.deleted;
}
return *this;
}
I need this file to be apprpriate for a liabery user rather then what books are there. And really can't think, if anyone has a spare 20mins it would be much appreciated.
This is the question i'm answering.
a.Class Book
Write a class to represent books in stock with the following private data members as a starting point :
1.Title
2.Author
3.ISBN (unique)
4.Quantity in stock
Constructors must include default, copy and specific data. The class must have functions for editing the quantity in stock, and functions for accessing the other data members. It must also have functions for comparing title, author ISBN and quantity in stock. The extraction and assignment operators must be overloaded. You may add other functions.