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...
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...
(I AM IN A INTRO TO PROGRAMMING, PLEASE USE SIMPLE PSEUDOCODE IF POSSIBLE) Create pseudocode for...
(I AM IN A INTRO TO PROGRAMMING, PLEASE USE SIMPLE PSEUDOCODE IF POSSIBLE) Create pseudocode for a program for Hansel's Housecleaning Service. The program prompts the user for a customer's last name only. While the last name is not “zzz” your program will ask for the number of bathrooms and the number of other rooms to be cleaned and display the cleaning charge. You should use a sentinel-controlled while loop in your main loop logic. A customer name of “zzz”...
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 TO IMPLEMENT THIS IN JAVA PLEASE I want to create a small user input...
I WANT TO IMPLEMENT THIS IN JAVA PLEASE I want to create a small user input system for a university student, where they put the season and year of when they started their uni course. For example the system will ask "What year did you start your degree?", the user will input "Autumn/2022" as a string. Now from a string format as shown, it should take that user input and calculate for example +2 or +3 years to the date....
Write in c++ as simple as possible In a right triangle, the square of the length...
Write in c++ as simple as possible In a right triangle, the square of the length on one side is equal to the sum of the squares of the lengths of the other two sides.  Write a program that prompts the user to enter the length of three sides of the tringle (as doubles) and the outputs a message indication whether the triangle is a right triangle.  You should split this into two functions (but only one .cpp file).  One function is main()...
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...
I need this code in C++ form using visual studios please: Create a class that simulates...
I need this code in C++ form using visual studios please: Create a class that simulates an alarm clock. In this class you should: •       Store time in hours, minutes, and seconds. Note if time is AM or PM. (Hint: You should have separate private members for the alarm and the clock. Do not forget to have a character variable representing AM or PM.) •       Initialize the clock to a specified time. •       Allow the clock to increment to the...
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++)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT