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

Add the following private attributes: String publisher String title String ISBN String imageName double price Create...
Add the following private attributes: String publisher String title String ISBN String imageName double price Create getter/setter methods for all data types Create a constructor that takes in all attributes and sets them Remove the default constructor Override the toString() method and return a String that represents the book object that is formatted nicely and contains all information (attributes) In the main class: Create a main method that throws FileNotFoundException Import java.io libraries Import java.util.Scanner Create a loop to read...
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...
TestLibrary.java Design and implement a class named Book. A book has a serial number, a title,...
TestLibrary.java Design and implement a class named Book. A book has a serial number, a title, an author, and a publisher. Create appropriate constructor(s) and accessor and mutator methods for the Book class. Add a static variable to the Book class and set its initial value to 100000000. When a new book is created, this static variable is automatically incremented by 1 and the new value is assigned as the serial number of the new book. Design and implement a...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT