subject

Write a class named book containing: three instance variables named title, author, and tableofcontents of type string. the value of tableofcontents should be initialized to the empty string. an instance variable named nextpage of type int, initialized to 1. a constructor that accepts two string parameters. the value of the first is used to initialize the value of title and the value of the second is used to initialize author. a method named addchapter that accepts two parameters. the first, of type string, is the title of the chapter; the second, is an integer containing the number of pages in the chapter. addchapter appends (that is concatenates) a newline followed by the chapter title followed by the string "" followed by the value of the nextpage instance variable to the tableofcontents. the method also increases the value of nextpage by the number of pages in the chapter. a method named getpages that accepts no parameters. getpages returns the number of pages in the book. a method named gettableofcontents that accepts no parameters. gettableofcontents returns the values of the tableofcontents instance variable. a method named tostring that accepts no parameters. tostring returns a string consisting of the value of title, followed by a newline character, followed by the value of author.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 16:30
Margins can be modified in the page layout tab or by using
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
Amanda needs to create an informative print brochure for her local library’s fundraiser dinner. what critical detail must she have before she starts designing the brochure?
Answers: 1
question
Computers and Technology, 22.06.2019 23:00
Which type of tab stop is most for weights and measurements?
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Best laptops for college [$100-$500 range]?
Answers: 2
You know the right answer?
Write a class named book containing: three instance variables named title, author, and tableofconte...
Questions
question
Social Studies, 24.03.2020 23:02
question
Mathematics, 24.03.2020 23:02
question
Biology, 24.03.2020 23:02
question
Mathematics, 24.03.2020 23:02
question
Mathematics, 24.03.2020 23:02
question
History, 24.03.2020 23:02
Questions on the website: 13722359