Question

In: Computer Science

Please write in C++ as simple as possible I want you to create a Book Class...

Please write in C++ as simple as possible

I want you to create a Book Class for a bookstore. I am not going to tell you what variables should go into it, that is for you to figure out (but you should have at least 5+). And then you must create a UML with all the variables and methods (like: the getters and setters, a default constructor, and a constructor that takes all the variables and finally the printValues() ).

Once you have the UML then create the three code files for the the Book.cpp file, and the Book.h file and the Main. In the main() create three book objects with values.

Solutions

Expert Solution

Book.h

#include<iostream>
#include<iomanip>
using namespace std;

class Book
{
private:
   int ISBN;
   string title, author, publication;
   int rating;
   double price;
public:
   Book();
   Book(int, string, string, string, int, double);
   int getISBN();
   string getTitle();
   string getAuthor();
   string getPublication();
   int getRating();
   double getPrice();
   void setISBN(int);
   void setTitle(string);
   void setAuthor(string);
   void setPublication(string);
   void setRating(int);
   void setPrice(double);
   void printValues();
};

CODE SCREENSHOT :

Book.cpp

#include "Book.h"

Book::Book()
{
   this->ISBN = 0;
   this->title = this->author = this->publication = "";
   this->rating = 0;
   this->price = 0.0;
}
Book::Book(int ISBN, string title, string author, string publication, int rating, double price)
{
   this->ISBN = ISBN;
   this->title = title;
   this->author = author;
   this->publication = publication;
   this->rating = rating;
   this->price = price;
}
int Book::getISBN() { return ISBN; }
string Book::getTitle() { return title; }
string Book::getAuthor() { return author; }
string Book::getPublication() { return publication; }
int Book::getRating() { return rating; }
double Book::getPrice() { return price; }
void Book::setISBN(int ISBN) { this->ISBN = ISBN; }
void Book::setTitle(string) { this->title = title; }
void Book::setAuthor(string) { this->author = author; }
void Book::setPublication(string) { this->publication = publication; }
void Book::setRating(int) { this->rating = rating; }
void Book::setPrice(double) { this->price = price; }
void Book::printValues()
{
   cout << "ISBN: " << getISBN() << "\nTitle: " << getTitle() << "\nAuthor: " << getAuthor() << "\nPublication: " << getPublication()
       << "\nrating: " << getRating() << "\nPrice: $" << setprecision(2) << fixed << getPrice() << endl;
}

CODE SCREENSHOT :

Main.cpp

#include "Book.h"

int main()
{
   Book book1(27718828, "Caesar and Cleopatra", "George Bernard Shaw", "ABC Publishers", 4, 874.45);
   Book book2(40012556, "Gulliver’s Travels", "Jonathan Swift", "XYZ Publishers", 4, 520);
   Book book3(18005351, "Invisible man", "H. G. Wells", "DERF Publishers", 3, 389.99);
   cout << "DISPLAYING ALL BOOKS:\n---------------------\nBOOK 1:\n";
   book1.printValues();
   cout << "\n\nBOOK 2:\n";
   book2.printValues();
   cout << "\n\nBOOK 3:\n";
   book3.printValues();
   cout << endl << endl;
   return 0;
}

CODE SCREENSHOT :

UML DIAGRAM :


Related Solutions

Please create using only For loops, as simple as possible as I am attending Java1 Create...
Please create using only For loops, as simple as possible as I am attending Java1 Create two Java programs that do the following: a. Use a for loop to print the numbers below on a single line as shown. 1 2 4 8 16 32 64 128. b. Ask the user to enter numbers using the for loop.  First ask the user how many numbers they will be entering in. Print the sum and average of the entered numbers. c. Write...
Week 10 - Please write in C++ as simple as possible RRCC has a schedule of...
Week 10 - Please write in C++ as simple as possible RRCC has a schedule of courses that includes: Subject (like: CSC) Course Number (like: 119) Section (like: 802) Credits (like: 3) Title Days (like: MW) Time (like 8:00am-9:15am) Instructor From this schedule information above create a class called RRCC_schedule (with a .cpp file and a .h file). Look at each item above and determine the type of data that will go into the variable. Then create a UML with...
As simple as possible. Please In C++ Computers are playing an increasing role in education. Write...
As simple as possible. Please In C++ Computers are playing an increasing role in education. Write a program that will help an elementary school student learn multiplication. Use rand() to produce two positive single digit integers. It should then display a question in the following format (assume 6 and 7 are randomly generated): How much is 6 * 7? The student then types the answer. Your program checks the student’s answer. If it is correct, print “Very good!” If the...
i want the asnwere as soon as possible please Pelzer Company reconciled its bank and book...
i want the asnwere as soon as possible please Pelzer Company reconciled its bank and book statement balances of Cash on August 31 and showed two cheques outstanding at that time, #5888 for $6,080 and #5893 for $1,453.00. The following information was available for the September 30, 2017, reconciliation: From the September 30, 2017, bank statement   BALANCE OF PREVIOUS STATEMENT ON AUG. 31/17 10,440.00   6 DEPOSITS AND OTHER CREDITS TOTALLING 19,446.00   9 CHEQUES AND OTHER DEBITS TOTALLING 24,130.00   CURRENT BALANCE...
can you please create the code program in PYTHON for me. i want to create array...
can you please create the code program in PYTHON for me. i want to create array matrix Nx1 (N is multiple of 4 and start from 16), and matrix has the value of elements like this: if N = 16, matrix is [ 4 4 4 4 -4 -4 -4 -4 4 4 4 4 -4 -4 -4 -4] if N = 64, matrix is [8 8 8 8 8 8 8 8 -8 -8 -8 -8 -8 -8 -8...
C/ C++ Preferably 1. Write a simple program where you create an array of single byte...
C/ C++ Preferably 1. Write a simple program where you create an array of single byte characters. Make the array 100 bytes long. In C this would be an array of char. Use pointers and casting to put INTEGER (4 byte) and CHARACTER (1 byte) data into the array and pull it out. YES, an integer can be put into and retrieved from a character array. It's all binary under the hood. In some languages this is very easy (C/C++)...
I want to write this program in java. Write a simple airline ticket reservation program in...
I want to write this program in java. Write a simple airline ticket reservation program in java.The program should display a menu with the following options: reserve a ticket, cancel a reservation, check whether a ticket is reserved for a particular person, and display the passengers. The information is maintained on an alphabetized linked list of names. In a simpler version of the program, assume that tickets are reserved for only one flight. In a fuller version, place no limit...
You cna hand write this if you want, Please code this in C Thank you PROBLEM...
You cna hand write this if you want, Please code this in C Thank you PROBLEM DESCRIPTION: Write a program to implement the following requirement: The program will read from standard input two things - a string str1 on the first line of stdin (this string may be an empty string) - a string str2 on the second line of stdin (this string may be an empty string) Note that stdin does not end with '\n'. The program will output...
Read the Book "The Patient Will See you now", write a 4-5 page paper. I want...
Read the Book "The Patient Will See you now", write a 4-5 page paper. I want you to look closely at the areas discussed in this book, discuss what areas will work well and what types of medicine it will work well within. Please use APA formatting and cite your references.
C++ Please write a exmaple of class template RedBlackTree.h.(It must be template!). I do not mind...
C++ Please write a exmaple of class template RedBlackTree.h.(It must be template!). I do not mind about details but please include the basic functions that are necessary for a RedBlackTree.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT