Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello object oriented C++ help please, I will repost this as many times as you want but please do it in one piece thanyou Book.cpp

Hello object oriented C++ help please, I will repost this as many times as you want but please do it in one piece thanyou

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed"Book.cpp"

#include #include #include "book.h"

using namespace std; Book::Book(string b_t, string b_a, int b_c, const Price & b_p) :book_price(b_p) { book_title = b_t; book_author = b_a; book_count = b_c; }

void Book::printBook() { cout

"Book.h"

#include #include "price.h" using namespace std;

#ifndef BOOK_H #define BOOK_H

class Book { private: string book_title; string book_author; int book_count; Price book_price; public: Book(string, string, int, const Price &); void printBook(); };

#endif

main.cpp:

#include #include #include "book.h"

using namespace std;

int main() {

//Test code for classes Book and Price Book b1("t0","a0",5,{2,75}); Price p2(2,22); Book bArr[3] = {b1, {"t1","a1",3,{6,55}}, {"t2","a2",2,p2}};

for (int i=0;i

price.cpp:

#include #include #include "price.h"

using namespace std;

Price::Price(int dd, int pp) { dinars=dd; piasters=pp; } void Price::printPrice() { cout

price.h:

#pragma once

class Price { private: int dinars; int piasters;

public: Price(int, int); void printPrice(); };

Use the this pointer in all of your setter functions The member functions that do not modify data members should be declared and defined as const Implement the class Price that represents prices in the Jordanian currency (dinars and piasters). The class should have: 1. data members to represent a. dinars (int), amount of dinars, must be >= 0) b. piasters (int), amount of piasters, must be in the range 0 to 99 inclusive 2. A parametrized constructor Price (with appropriate validation) 3. Appropriate setters for all data members with appropriate validation, force user to input correct values) 4. Getters for all data members 5. void printPrice, a member function to print the price in JD and piasters Submit two files for this part, price.h (for the class interface) and price.cpp (for the class implementation) Implement class Book that represents a book with the following: 1. Attributes a. book_title (string), b. book_author (string), c. book_count (int), to represent the available number of copies of the book d. book_price (Price). 2. A parameterized constructor to set all Book data members 3. setters for all data members 4. getters for all data members 5. void modifyBookCount(int n), modify current value of book_count by the amount n (n can be positive or negative). 6. void printBook(), a member function to print the book information title, author, and price). Submit two files for this part, book.h (for the class interface) and book.cpp (for the class implementation) Implement class Bookshop that represents a shop that sells books. This class should have: LBody to it. sha the following attributes: max_num_titles (int), to represent the maximum number titles, (must be positive integr) Book + bookstr, A pointer of type Book, will be used to create a dynamic array of type Book current (int), that represents number of current book titles in the bookshop, (must be >=0) The class should have a default constructor set max_num_titles to 10, and current to 0 create a dynamic array of type Book and size max_num_titles, and make booksPtr point to it A parameterized constructor that will receive arguments for all the data members initialize all the data members, with appropriate validation. Create a dynamic array of type Book and size max_num_titles, and make booksPtr point -LibXry(): Deallocates the dynamic array of Bookshop. isEmpty(), a boolean function that returns true if current==0. and false otherwise. isFull(), a boolean function that returns true if current==max_num_titles, and false otherwise. int findTitle(string title) returns the index of the book with that title if found in booksPtr array, otherwise returns - 1. HINT: you can use string compare function from the string library void addBook (const Book & b): this function does the following: add book b into the end of list bookstr, if the Bookshop is not full and book title does not already exist in the list. If the title of book b is already in list, then increment the count available copies of this book by 1, and then print the updated number of copies. If the title of the book b is not in list, but the list is full, then print a suitable message to say that the add book operation failed. void adjustMaxNumTitles(int n), a member function to increase/resize the size of the dynamic array pointed to by booksPtr by the amount n without losing its original contents. The function must also update max_num_titles accordingly. Submit two files for this part, bookshop.h and bookshop.cpp (Submit one file for this: main.cpp): 1. void printBookTitles (const Bookshop &), as a global friend function of class Bookshop to print information about all book titles in the bookshop dynamic array, and the current number book titles. 2. In the main function, do the following: 2.1. define an array, booksArray, of type Book with size equal to SIZE 2.1.1. SIZE should be declared and initialized to 8 2.1.2. You must initialize booksArray with meaningful data using one of the following methods: from user, from a data file, or from an initialization list 2.2. Define the object bshop of type Bookshop such that it will have a dynamic array of size 10. That dynamic array would initially be empty (i.e., with no books). 2.3. Add the books from booksArray to the dynamic array of bShop, one by one using a loop and a proper function call. 2.4. Add the third book from booksArray to the dynamic array of bShop 2.5. Using a proper function call, resize the dynamic array of the object bShop by adding space for 5 more objects of type Book. 2.6. Search for the title of the 4th book of booksArray in bShop and display a useful message to show the search result. 2.7. Print the details of all bShop list of books

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+Will the humor enhance the message?

Answered: 1 week ago

Question

Classify delivery styles by type.

Answered: 1 week ago