Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ please without using pointers O Q1: Implement the following classes: Line class attribute content (as private string) Default and initializer constructors destructor I

image text in transcribed

image text in transcribed

in c++ please without using pointers

O Q1: Implement the following classes: Line class attribute content (as private string) Default and initializer constructors destructor I setters and getters Define print function that prints line contents. Void concat(line &12), which concatenates the two lines contents and empty the received one. O HasSameContent(Line &12) which compares two objects and returns back true if they both have the same exact content. O Page class o two private members: 1) array of 30 lines and 2) page number. The constructor should ioitialize the lines to empty string and page number to 0. Destructor Setters (lines and page number) and one getter for page number AddLine member function that receives a line object and adds it to current page. The line will be added after last non-empty line. If number of lines is already 30, it will display a message "cannot add line, page is full. o print function that prints page lines line by line. HasMoreLines(Page &p2) which compares the two pages and return back true if original object has more Lines than object p2. Book class, o private attributes: 1)a dynamic array of pages, 2) the current number of pages. Constructor and copy constructor Destructor Getter for number of pages AddPage member function. It receives a page object and adds it to the book. Each time a page is added, it is assigned a page number based on sequence of addition Print function to print the book pages page by page, the function should print a separator line between every two pages. O O O HasMorePages(Book &B2) which compares the two book objects and return back true if original object has more pages than object B2. Has Morelines(Book &B2) which compares the two book objects and return back true if original object has more Lines than object B2. You have to separate header from implementation for all classes O Q2: Write a main function that does the following: 1. Has array of lines, where array size is 18. Input using loop values inside the objects of lines array. Make your values as the following: for line 1 "AAAAAA, for line 2 "BBBBBB", for line 3 "CCCCCC" and so on. 2. define an array of pages of size 6. add 3 lines per page from lines array defined in point 1. First 3 lines go to first page, second 3 lines go to second page and so on. 3. Define two book objects b1, and b2 where bi has first 2 pages while b2 has last 3 pages. Use AddPage function to add the specified pages for each book. Print the pages inside b2. 5. Print the total number of pages added in both books (b1 and 62). 6. Print which book has more pages, and which book has more lines B1 or B2. 7. Define book class pointer variable. Create a new book object and make the pointer point to it. Use AddPage function to add pages 2,3,4 and 5 to the book. 8. Delete last object that was created dynamically! 4. O Q1: Implement the following classes: Line class attribute content (as private string) Default and initializer constructors destructor I setters and getters Define print function that prints line contents. Void concat(line &12), which concatenates the two lines contents and empty the received one. O HasSameContent(Line &12) which compares two objects and returns back true if they both have the same exact content. O Page class o two private members: 1) array of 30 lines and 2) page number. The constructor should ioitialize the lines to empty string and page number to 0. Destructor Setters (lines and page number) and one getter for page number AddLine member function that receives a line object and adds it to current page. The line will be added after last non-empty line. If number of lines is already 30, it will display a message "cannot add line, page is full. o print function that prints page lines line by line. HasMoreLines(Page &p2) which compares the two pages and return back true if original object has more Lines than object p2. Book class, o private attributes: 1)a dynamic array of pages, 2) the current number of pages. Constructor and copy constructor Destructor Getter for number of pages AddPage member function. It receives a page object and adds it to the book. Each time a page is added, it is assigned a page number based on sequence of addition Print function to print the book pages page by page, the function should print a separator line between every two pages. O O O HasMorePages(Book &B2) which compares the two book objects and return back true if original object has more pages than object B2. Has Morelines(Book &B2) which compares the two book objects and return back true if original object has more Lines than object B2. You have to separate header from implementation for all classes O Q2: Write a main function that does the following: 1. Has array of lines, where array size is 18. Input using loop values inside the objects of lines array. Make your values as the following: for line 1 "AAAAAA, for line 2 "BBBBBB", for line 3 "CCCCCC" and so on. 2. define an array of pages of size 6. add 3 lines per page from lines array defined in point 1. First 3 lines go to first page, second 3 lines go to second page and so on. 3. Define two book objects b1, and b2 where bi has first 2 pages while b2 has last 3 pages. Use AddPage function to add the specified pages for each book. Print the pages inside b2. 5. Print the total number of pages added in both books (b1 and 62). 6. Print which book has more pages, and which book has more lines B1 or B2. 7. Define book class pointer variable. Create a new book object and make the pointer point to it. Use AddPage function to add pages 2,3,4 and 5 to the book. 8. Delete last object that was created dynamically! 4

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

Recommended Textbook for

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

What are the five principles of lean thinking?

Answered: 1 week ago