Question

In: Computer Science

The most common attributes of a book are the Book Title, and ISBN. The most common...

The most common attributes of a book are the Book Title, and ISBN. The most common functions are to set the Book Title, and ISBN,

Write the code to implement this problem.

1. Write the UML Diagram that represents this class Book

2. Use code blocks editor and in C++

Write a header file Book with these properties.

Write the implementation file for the member functions.

Solutions

Expert Solution

cpp code:

book.h

#ifndef BOOK_H_INCLUDED
#define BOOK_H_INCLUDED

//class
class Book
{
//attribute
std::string title;
std::string ISBN;
public:
//methods
Book();
void setBook(std::string t,std::string i);
std::string getTitle();
std::string getISBN();
};


#endif // BOOK_H_INCLUDED

book.cpp

#include <iostream>
#include "book.h"

using namespace std;

//default constructor
Book::Book()
{
this->title="";
this->ISBN="";
}

//set title and isbn no
void Book::setBook(string t,string i)
{
this->title=t;
this->ISBN=i;
}
//return title
string Book::getTitle()
{
return title;
}
//return isbn
string Book::getISBN()
{
return ISBN;
}

main.cpp

#include <iostream>
#include "book.h"

using namespace std;

int main()
{
//object for book class
Book bk;

//set values
bk.setBook("OOPS","123-423-5003");

//print values
cout <<"Title: "<< bk.getTitle() << endl;
cout <<"\nISBN: "<< bk.getISBN() << endl;
return 0;
}

output:

UML for Book:


//for any clarification , please do comments, if you found this solution useful,please give me thumbs up


Related Solutions

Write an ISBN Validator in C language What are ISBN? ISBN, or International Standard Book Number,...
Write an ISBN Validator in C language What are ISBN? ISBN, or International Standard Book Number, is a numeric identifier for commercially printed books. Prior to 2007, they had 10 digits, but all newly issued ISBN use 13 digits. They are used to uniquely identify a book and consist of several portions. These include the registrant group, publisher, title, and a check digit. The registrant group indicates where the publisher is located. For example a registrant group of 0 or...
Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition,...
Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition, price), PK: ISBN, FK: published_by refs Publisher, previous_edition refs Book. Author (SSN, first_name, last_name, address, income), PK: SSN. Write (aSSN, bISBN), PK: (aSSN, bISBN), FK: aSSN refs Author, bISBN refs Book. Editor (SSN, first_name, last_name, address, salary, works_for, book_count), PK: SSN, FK: works_for refs Publisher. Edit (eSSN, bISBN), PK: (eSSN, bISBN), FK: eSSN refs Editor, bISBN refs Book. Author_Editor (aeSSN, hours), PK: aeSSN, FK:...
Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition,...
Consider the following schema: Publisher (name, phone, city), PK: name. Book (ISBN, title, year, published_by, previous_edition, price), PK: ISBN, FK: published_by refs Publisher, previous_edition refs Book. Author (SSN, first_name, last_name, address, income), PK: SSN. Write (aSSN, bISBN), PK: (aSSN, bISBN), FK: aSSN refs Author, bISBN refs Book. Editor (SSN, first_name, last_name, address, salary, works_for, book_count), PK: SSN, FK: works_for refs Publisher. Edit (eSSN, bISBN), PK: (eSSN, bISBN), FK: eSSN refs Editor, bISBN refs Book. Author_Editor (aeSSN, hours), PK: aeSSN, FK:...
Teen Book Review: The grieving teen: A guide for teenagers and their frends. ISBN: 0684868040 ISBN-13:...
Teen Book Review: The grieving teen: A guide for teenagers and their frends. ISBN: 0684868040 ISBN-13: 9780684868042 Authors:Helen FitzGerald THE FOLLOWING QUESTIONS ARE NOT CONTENT FROM THE BOOK BUT THOUGHTS FROM THE BOOK Recently many publishers have responded to the need for books that are designed to help adults discuss a difficult topic, death, with young children, and/or teens. You are to select one book (many are on Amazon), written for teens, and evaluate it based on what we have...
CIS- Python (Business: check ISBN-10) An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10....
CIS- Python (Business: check ISBN-10) An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10. The last digit, d10, is a checksum, which is calculated from the other nine digits using the following formula: (d1 * 1 + d2 * 2 + d3 * 3 + d4 * 4 + d5 * 5 + d6 * 6 + d7 * 7 + d8 * 8 + d9 * 9) % 11 If the checksum is 10, the last digit...
Imagine a new book that is to be released. Construct the attributes (i.e., the value of...
Imagine a new book that is to be released. Construct the attributes (i.e., the value of independent variables) of this, and estimate the sales rank of it when it is sold on Amazon.com
What are the most important attributes of an output stage amplifier?
  a)       What are the most important attributes of an output stage amplifier? b)      Explain the importance of high efficiency in high power circuits. c)       Explain how the class AB stage circuit overcomes the dead zone in output voltage current and voltage. d)      Explain the operation of the CMOS class AB output stage circuit. e)      How does a class D output amplifier stage differ from class A, B, or AB stages?
Book ISBN: 1111535221 Financial and Manengarial Accounting using excell for success Question: Continuing Problem Pg. 99-100....
Book ISBN: 1111535221 Financial and Manengarial Accounting using excell for success Question: Continuing Problem Pg. 99-100. The transaction completed by PS Music during June 2012 were described at the end of Chapter 1. The follwoing transaction where completed during July, the second monh of the business opperations: July 1. Pat Sharp made an additional investment in PS Music in exchange for capital stock by depositing $4,000 in PS Musics checking account.        1. Instead of continuing to share office space...
textbook: Costanzo, L.S. (2018). Physiology (6th ed.). Philadelphia, PA: Elsevier. ISBN: 9780323478816 (e-book – 9780323511896). Based...
textbook: Costanzo, L.S. (2018). Physiology (6th ed.). Philadelphia, PA: Elsevier. ISBN: 9780323478816 (e-book – 9780323511896). Based on readings from chapter 10 of the Physiology textbook and further scientific research into current literature, discuss the following in 400 words minimum. 1. Give a description of the physiologic basis of the different types of hormonal birth control. 2. Based on the physiology described in Q1, identify which of these prevent fertilization 3. Based on the physiology in Q1, identify which of these...
Create at least 25 random ISBN keys and insert all random ISBN keys into a Binary...
Create at least 25 random ISBN keys and insert all random ISBN keys into a Binary Tree. Write a function to determine if the Binary Tree is a BST or not a BST. In addition validate AVL balance condition. Hint: Should you proceed to validate AVL if the binary tree did not produce BST? Report the problems. You don’t need to fix anything. Also, do not hard code the tree inside the code. This needs to be done in Java.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT