Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / A Chapter object should get instantiated using the name of the Chapter and the number of pages

A Chapter object should get instantiated using the name of the Chapter and the number of pages

Computer Science

A Chapter object should get instantiated using the name of the Chapter and the number of pages. The name can be 3 maximum of 50
characters long and the pages of the chapters cannot be more than 200. ff any of this information is not provided or if they are invalid, the
‘object is created in an invalid state.
A Chapter is displayed 3s fallows ( Valid:
© Name in SO spaces, filled with dots ‘., left-justified
© Number of pages in 3 spaces right justified
*°  Newine
tthe chapter is invalid, it should just print: “iawalid Qugtee” and go to newline.
For example if the Chapter name is Java and it is 60 pages, it should print as folows:
TVD. os ccescntccencctccmsccnsccnsesscctscnsccnss GF
Bock
A Book is crested using ts name, number of chapters and an array of Chapters ( with “number of chapters elements).
‘The length of the name ar the number of chapters is unknown.
‘The following are the publc functions required far the Class Book.
Bool istapty( jconst;
retums true if the Book is empty or invalid, otherwise, it returns false:
Goold addchaptar{canst char? chapter nase, int noGfPages};
Adds a Chapter to a Book only if the name and noOfPages are valid values (to create a Chapter with).
wold display()consts
Displays the Book as follows, if it is valict
© prints “Book Name: *
© prints the book name value
© NEWLINE
© prints “No of chapters: *
© prints the number of chapters
© prints all the Chapters in individual lines if the book is invalid it will print:
© othenwice, prints “Invaled book object’:

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE