Untitled

mail@pastecode.io avatar
unknown
plain_text
22 days ago
7.2 kB
1
Indexable
Never
Create a class Hierarchy for Movies
	- attributes
	- behaviour
CDMovies
	Refer
	Lend
WebMovies
	Buy

libmain.cpp by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:02 pm
libmain.cpp
#include "book.h"   using namespace std ;... by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:02 pm
#include "book.h"
 
using namespace std;
 
int main()
{
    Book book("10010039394", "Harry Potter and the Prisoner of Az", "Rebecca Flitch", 1000.0 );
 
    vector<string> addAuthors{"Dr. Spock", "Newt Fletcher"};
 
    book.addAdditionalAuthor("Roberta Contsance");
    book.addAdditionalAuthor(addAuthors);
 
    vector<string> categories{"Magic", "children"};
 
    book.addCategory("Fiction");
    book.addCategory(categories);
    book.DisplayBook();
}
book.h by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:02 pm
book.h
#include <vector> #include <string>   #pr... by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:02 pm
#include <vector>
#include <string>
 
#pragma once
 
using namespace std;
 
class Book
{
    string ISBNno;
    string name;
    string author;
    vector<string> additionalAuthors;
    vector<string> bookCategory;
 
    float cost;
protected:
    int status;
public:
    Book(string isbn, string name,
         string author, float cost);
    const string getISBN(void) const;
    const string getAuthor(void) const;
    float getCost(void) const;
    int getStatus(void) const;
 
    void setCost(float cost);
 
    const vector<string> &getAdditionalAuthors(void) const;
    void addAdditionalAuthor(string author);
    void addAdditionalAuthor(vector<string> authors);
 
    const vector<string> &getCategories(void) const;
    void addCategory(string category);
    void addCategory(vector<string> categories);
 
    void Lend(void);
    virtual void Return(void);
    virtual void Lost(void);
    virtual void DisplayBook(void);
};
 
 
book.cpp by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:02 pm
book.cpp
#include <iostream> #include "book.h" #in... by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:02 pm
#include <iostream>
#include "book.h"
#include <vector>
 
Book::Book(std::string isbn, std::string name, std::string author,
            float cost) : ISBNno(isbn), name(name), author(author),
                          cost(cost), status(1)
{
}
 
const std::string Book::getISBN(void) const
{
    return this->ISBNno;
}
 
const std::string Book::getAuthor(void) const
{
    return this->author;
}
 
float Book::getCost(void) const
{
    return this->cost;
}
int Book::getStatus(void) const
{
    return this->status;
}
 
void Book::setCost(float cost)
{
    this->cost = cost;
}
 
void Book::Lend(void)
{
    if (this->status == 1)
    {
        this->status = 2;
    }
 
}
void Book::Return(void)
{
    if (this->status == 2)
    {
        this->status = 1;
    }
}
 
void Book::Lost(void)
{
    this->status = 3;
}
 
 
void Book::DisplayBook(void)
{
    std::cout << "{" << this->ISBNno << ", "
              << this->name << ", "
              << this->author << ", "
              << this->cost << ", "
              << this->status << std::endl;
    std::cout << "[";
    for (auto val : this->additionalAuthors)
    {
        std::cout << val << ", ";
    }
    std::cout << "]" << std::endl;
    std::cout << "[";
    for (auto val : this->bookCategory)
    {
        std::cout << val << ", ";
    }
    std::cout << "]" << std::endl;
 
}
 
const std::vector<string> &Book::getAdditionalAuthors(void) const
{
    return this->additionalAuthors;
}
 
void Book::addAdditionalAuthor(string author)
{
    this->additionalAuthors.push_back(author);
}
 
void Book::addAdditionalAuthor(vector<string> authors)
{
    for (auto val : authors)
    {
        this->additionalAuthors.push_back(val);
    }
}
 
const std::vector<string> &Book::getCategories(void) const
{
    return this->bookCategory;
}
 
void Book::addCategory(string category)
{
    this->bookCategory.push_back(category);
}
 
void Book::addCategory(vector<string> categories)
{
    for (auto val : categories)
    {
        this->bookCategory.push_back(val);
    }
}
 
encylopediaBook.h by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:02 pm
encylopediaBook.h
#pragma once #include "book.h"   #include... by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:02 pm
#pragma once
#include "book.h"
 
#include <string>
using namespace std;
 
class EnclyclopediaBook : public Book
{
    int type;
    string publisher;
 
public:
    EnclyclopediaBook(string isbn, string name, string author,
                float cost, int type, string publisher);
    int getType(void);
    void setType(int type);
    const string getPublisher(void);
 
    void Refer(void);
    void Return(void) override;
};
encyclopediaBook.cpp by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:03 pm
encyclopediaBook.cpp
#include "enclyclopediaBook.h"   Enclyclop... by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:03 pm
#include "enclyclopediaBook.h"
 
EnclyclopediaBook::EnclyclopediaBook(string isbn, string name, string author,
            float cost, int type, string publisher) : Book(isbn,
                                                           name, author,
                                                           cost), type(type),
                                                           publisher(publisher)
{
    ;
}
 
int EnclyclopediaBook::getType(void)
{
    return this->type;
}
 
void EnclyclopediaBook::setType(int type)
{
    this->type = type;
}
 
const string EnclyclopediaBook::getPublisher(void)
{
    return this->publisher;
}
 
void EnclyclopediaBook::Refer(void)
{
    if (this->status == 1)
        this->status = 4;
}
 
void EnclyclopediaBook::Return(void)
{
    if (this->status == 2 || this->status == 4)
        this->status = 1;
}
 
 
fictionbook.h by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:03 pm
fictionbook.h
#pragma once #include "book.h" #include ... by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:03 pm
#pragma once
#include "book.h"
#include <string>
 
using namespace std;
 
class FictionBook : public Book
{
    int type;
    string region;
public:
    FictionBook(string isbn, string name, string author,
                float cost, int type, string region);
    int getType(void);
    const string getRegion(void);
    void setRegion(string region);
 
    void Buy(void);
};
 
fictionbook.cpp by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:03 pm
fictionbook.cpp
#include "fictionBook.h"   FictionBook ::F... by Sanjeevan (Unverified)
Sanjeevan (Unverified)
6:03 pm
#include "fictionBook.h"
 
FictionBook::FictionBook(string isbn, string name, string author,
            float cost, int type, string region) : Book(isbn,
                                                        name, author,
                                                        cost), type(type),
                                                        region(region)
{
    ;
}
 
int FictionBook::getType(void)
{
    return this->type;
}
 
const string FictionBook::getRegion(void)
{
    return this->region;
}
 
void FictionBook::setRegion(string region)
{
    this->region = region;
}
 
 
void FictionBook::Buy(void)
{
   
}
 
has context menu


has context menu
Leave a Comment