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 19:30
Keep your choice of a major there is probably no single correct choice.
Answers: 1
question
Computers and Technology, 24.06.2019 09:00
Technician a says that a new replacement part is always good. technician b says that sometimes recent repair work will be the cause of a complaint. who is correct? a. both technicians a and b b. technician a c. technician b d. neither technician a nor b
Answers: 3
question
Computers and Technology, 24.06.2019 13:50
Write a program that performs a simple n-body simulation, called "jumping leprechauns." this simulation involves n leprechauns, numberd 1 to n. it maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, g_i = 1000000 for each i = 1,. in addition, the simulation also maintains, for each leprachaun,i, a place on the horizon, which is represented as a double-precision floating point number, x_i. in each iteration of the simulation, the simulation processes the leprachauns in order. processing a leprachaun i during its iteration begins by computing a new place on the horizon for i, which is determined by the assignment:
Answers: 3
question
Computers and Technology, 24.06.2019 14:00
Which describes careers that have similar education requirements but different qualifications? product safety engineers and materials engineers industrial safety engineers and industrial health engineers quality control systems managers and inspectors industrial safety and health engineers and hand packers
Answers: 3
You know the right answer?
Write a class named book containing: three instance variables named title, author, and tableofconte...
Questions
question
Mathematics, 25.10.2019 12:43
question
Social Studies, 25.10.2019 12:43
question
Mathematics, 25.10.2019 12:43
question
Mathematics, 25.10.2019 12:43
question
Mathematics, 25.10.2019 12:43
Questions on the website: 13722360